Files
cinny/src/app/utils/draft.test.ts
T

28 lines
910 B
TypeScript
Raw Normal View History

import { test } from 'node:test';
import assert from 'node:assert/strict';
import { Descendant } from 'slate';
import { hasMsgDraft } from './draft';
const paragraph = (text: string): Descendant =>
({ type: 'paragraph', children: [{ text }] }) as unknown as Descendant;
test('hasMsgDraft is false for an empty array', () => {
assert.equal(hasMsgDraft([]), false);
});
test('hasMsgDraft is false for an empty paragraph (empty editor)', () => {
assert.equal(hasMsgDraft([paragraph('')]), false);
});
test('hasMsgDraft is false for whitespace-only content', () => {
assert.equal(hasMsgDraft([paragraph(' \n ')]), false);
});
test('hasMsgDraft is true when there is real text', () => {
assert.equal(hasMsgDraft([paragraph('hello')]), true);
});
test('hasMsgDraft is true across multiple paragraphs with text', () => {
assert.equal(hasMsgDraft([paragraph(''), paragraph(' hi ')]), true);
});