Skip to content

Commit a373b9d

Browse files
committed
test(json-crdt-peritext-ui): 💍 add test case for "marker" data update events
1 parent e7235fd commit a373b9d

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

src/json-crdt-extensions/peritext/events/__tests__/marker.spec.ts

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ const testSuite = (getKit: () => Kit) => {
107107
]],
108108
],
109109
});
110-
expect(kit.toHtml()).toBe('<p>abcdefgh</p><blockquote><p><ul><li>ijklmnopqrstuvwxyz</li></ul></p></blockquote>');
110+
expect(kit.toHtml()).toBe('<p>abcdefgh</p><blockquote><p><ul data-attr=\'{"type":"tasks"}\'><li>ijklmnopqrstuvwxyz</li></ul></p></blockquote>');
111111
kit.et.marker({
112112
action: 'upd',
113113
target: 'type',
114114
ops: [
115115
['remove', [1]],
116116
],
117117
});
118-
expect(kit.toHtml()).toBe('<p>abcdefgh</p><blockquote><ul><li>ijklmnopqrstuvwxyz</li></ul></blockquote>');
118+
expect(kit.toHtml()).toBe('<p>abcdefgh</p><blockquote><ul data-attr=\'{"type":"tasks"}\'><li>ijklmnopqrstuvwxyz</li></ul></blockquote>');
119119
kit.et.marker({
120120
action: 'upd',
121121
target: 'type',
@@ -178,6 +178,35 @@ const testSuite = (getKit: () => Kit) => {
178178
expect(slice?.nestedType().tag(0).discriminant()).toBe(2);
179179
});
180180
});
181+
182+
describe('data', () => {
183+
test('can add and update tag data', () => {
184+
const kit = setup();
185+
kit.et.cursor({at: [8]});
186+
kit.et.marker({action: 'ins', type: SliceTypeCon.blockquote});
187+
expect(kit.toHtml()).toBe('<p>abcdefgh</p><blockquote>ijklmnopqrstuvwxyz</blockquote>');
188+
kit.et.marker({
189+
action: 'upd',
190+
target: ['data', 0],
191+
ops: [
192+
['add', '/author', 'Quasimodo'],
193+
['add', '/source', 'Journal of Hunchbacks'],
194+
],
195+
});
196+
expect(kit.toHtml()).toBe('<p>abcdefgh</p><blockquote data-attr=\'{"author":"Quasimodo","source":"Journal of Hunchbacks"}\'>ijklmnopqrstuvwxyz</blockquote>');
197+
kit.et.marker({
198+
action: 'upd',
199+
target: ['data', 0],
200+
ops: [
201+
['merge', '', {
202+
author: 'Pierre Gringoire',
203+
source: 'Journal of Hunchbacks',
204+
}],
205+
],
206+
});
207+
expect(kit.toHtml()).toBe('<p>abcdefgh</p><blockquote data-attr=\'{"author":"Pierre Gringoire","source":"Journal of Hunchbacks"}\'>ijklmnopqrstuvwxyz</blockquote>');
208+
});
209+
});
181210
});
182211

183212
describe('scenarios', () => {

0 commit comments

Comments
 (0)