/* eslint-disable no-console */

import type { CrystallizeRichText } from '../rich-text-editor';
import { parseInitialState } from './parse-initial-state';

describe('RichTextEditor parseInitialState', () => {
  it('ensures that the initial state is an array', async () => {
    expect(
      parseInitialState({
        richText: {
          kind: 'block',
          type: 'paragraph',
          textContent: 'hello',
        },
      }),
    ).toEqual([
      {
        kind: 'block',
        type: 'paragraph',
        textContent: 'hello',
      },
    ]);
  });

  it('ensures that all root nodes are block elements', async () => {
    expect(
      parseInitialState({
        richText: [
          {
            kind: 'inline',
            textContent: 'hello',
          },
        ],
      }),
    ).toEqual([
      {
        kind: 'block',
        type: 'paragraph',
        children: [
          {
            kind: 'inline',
            textContent: 'hello',
          },
        ],
      } as CrystallizeRichText,
    ]);
  });
});
