Skip to content

Commit

Permalink
Add a test to verify we don't have always false-positive
Browse files Browse the repository at this point in the history
  • Loading branch information
e1himself committed Jul 15, 2022
1 parent ce69611 commit 0c23cb0
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,44 @@ import { createEditor } from '#modules/editor';
import { isEditorValueEqual } from './isEditorValueEqual';

describe('slate-editor - isEditorValueEqual', () => {
it('should return true for equivalent values', () => {
const editor = createEditor(createSlateEditor(), () => []);

const a = [
{
type: 'paragraph',
children: [{ text: 'Hello', bold: true }],
},
];
const b = [
{
type: 'paragraph',
children: [{ text: 'Hello', bold: true }],
},
];

expect(isEditorValueEqual(editor, a, b)).toBe(true);
});

it('should return false for non-equivalent values', () => {
const editor = createEditor(createSlateEditor(), () => []);

const a = [
{
type: 'paragraph',
children: [{ text: 'Hello', bold: true }],
},
];
const b = [
{
type: 'paragraph',
children: [{ text: 'hello', bold: true }],
},
];

expect(isEditorValueEqual(editor, a, b)).toBe(false);
});

it('should consider structural equality', () => {
const editor = createEditor(createSlateEditor(), () => []);

Expand Down

0 comments on commit 0c23cb0

Please sign in to comment.