test(editor): remove jsx snapshot (#9463)
This commit is contained in:
@@ -865,68 +865,6 @@ describe('getBlock', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// Inline snapshot is not supported under describe.parallel config
|
||||
describe('collection.exportJSX works', () => {
|
||||
it('collection matches snapshot', () => {
|
||||
const options = createTestOptions();
|
||||
const collection = new DocCollection(options);
|
||||
collection.meta.initialize();
|
||||
const doc = collection.createDoc({ id: 'doc:home' });
|
||||
|
||||
doc.addBlock('affine:page', { title: new doc.Text('hello') });
|
||||
|
||||
expect(collection.exportJSX()).toMatchInlineSnapshot(`
|
||||
<affine:page
|
||||
prop:count={0}
|
||||
prop:items={[]}
|
||||
prop:style={{}}
|
||||
prop:title="hello"
|
||||
/>
|
||||
`);
|
||||
});
|
||||
|
||||
it('empty collection matches snapshot', () => {
|
||||
const options = createTestOptions();
|
||||
const collection = new DocCollection(options);
|
||||
collection.meta.initialize();
|
||||
collection.createDoc({ id: 'doc:home' });
|
||||
|
||||
expect(collection.exportJSX()).toMatchInlineSnapshot('null');
|
||||
});
|
||||
|
||||
it('collection with multiple blocks children matches snapshot', () => {
|
||||
const options = createTestOptions();
|
||||
const collection = new DocCollection(options);
|
||||
collection.meta.initialize();
|
||||
const doc = collection.createDoc({ id: 'doc:home' });
|
||||
doc.load(() => {
|
||||
const rootId = doc.addBlock('affine:page', {
|
||||
title: new doc.Text(),
|
||||
});
|
||||
const noteId = doc.addBlock('affine:note', {}, rootId);
|
||||
doc.addBlock('affine:paragraph', {}, noteId);
|
||||
doc.addBlock('affine:paragraph', {}, noteId);
|
||||
});
|
||||
|
||||
expect(collection.exportJSX()).toMatchInlineSnapshot(/* xml */ `
|
||||
<affine:page
|
||||
prop:count={0}
|
||||
prop:items={[]}
|
||||
prop:style={{}}
|
||||
>
|
||||
<affine:note>
|
||||
<affine:paragraph
|
||||
prop:type="text"
|
||||
/>
|
||||
<affine:paragraph
|
||||
prop:type="text"
|
||||
/>
|
||||
</affine:note>
|
||||
</affine:page>
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('flags', () => {
|
||||
it('update flags', () => {
|
||||
const options = createTestOptions();
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
// checkout https://vitest.dev/guide/debugging.html for debugging tests
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { yDocToJSXNode } from '../utils/jsx.js';
|
||||
|
||||
describe('basic', () => {
|
||||
it('serialized doc match snapshot', () => {
|
||||
expect(
|
||||
yDocToJSXNode(
|
||||
{
|
||||
'0': {
|
||||
'sys:id': '0',
|
||||
'sys:children': ['1'],
|
||||
'sys:flavour': 'affine:page',
|
||||
},
|
||||
'1': {
|
||||
'sys:id': '1',
|
||||
'sys:children': [],
|
||||
'sys:flavour': 'affine:paragraph',
|
||||
'prop:text': [],
|
||||
'prop:type': 'text',
|
||||
},
|
||||
},
|
||||
'0'
|
||||
)
|
||||
).toMatchInlineSnapshot(`
|
||||
<affine:page>
|
||||
<affine:paragraph
|
||||
prop:type="text"
|
||||
/>
|
||||
</affine:page>
|
||||
`);
|
||||
});
|
||||
|
||||
it('block with plain text should match snapshot', () => {
|
||||
expect(
|
||||
yDocToJSXNode(
|
||||
{
|
||||
'0': {
|
||||
'sys:id': '0',
|
||||
'sys:flavour': 'affine:page',
|
||||
'sys:children': ['1'],
|
||||
'prop:title': 'this is title',
|
||||
},
|
||||
'1': {
|
||||
'sys:id': '2',
|
||||
'sys:flavour': 'affine:paragraph',
|
||||
'sys:children': [],
|
||||
'prop:type': 'text',
|
||||
'prop:text': [{ insert: 'just plain text' }],
|
||||
},
|
||||
},
|
||||
'0'
|
||||
)
|
||||
).toMatchInlineSnapshot(`
|
||||
<affine:page
|
||||
prop:title="this is title"
|
||||
>
|
||||
<affine:paragraph
|
||||
prop:text="just plain text"
|
||||
prop:type="text"
|
||||
/>
|
||||
</affine:page>
|
||||
`);
|
||||
});
|
||||
|
||||
it('doc record match snapshot', () => {
|
||||
expect(
|
||||
yDocToJSXNode(
|
||||
{
|
||||
'0': {
|
||||
'sys:id': '0',
|
||||
'sys:flavour': 'affine:page',
|
||||
'sys:children': ['1'],
|
||||
'prop:title': 'this is title',
|
||||
},
|
||||
'1': {
|
||||
'sys:id': '2',
|
||||
'sys:flavour': 'affine:paragraph',
|
||||
'sys:children': [],
|
||||
'prop:type': 'text',
|
||||
'prop:text': [
|
||||
{ insert: 'this is ' },
|
||||
{
|
||||
insert: 'a ',
|
||||
attributes: { link: 'http://www.example.com' },
|
||||
},
|
||||
{
|
||||
insert: 'link',
|
||||
attributes: { link: 'http://www.example.com', bold: true },
|
||||
},
|
||||
{ insert: ' with', attributes: { bold: true } },
|
||||
{ insert: ' bold' },
|
||||
],
|
||||
},
|
||||
},
|
||||
'0'
|
||||
)
|
||||
).toMatchInlineSnapshot(`
|
||||
<affine:page
|
||||
prop:title="this is title"
|
||||
>
|
||||
<affine:paragraph
|
||||
prop:text={
|
||||
<>
|
||||
<text
|
||||
insert="this is "
|
||||
/>
|
||||
<text
|
||||
insert="a "
|
||||
link="http://www.example.com"
|
||||
/>
|
||||
<text
|
||||
bold={true}
|
||||
insert="link"
|
||||
link="http://www.example.com"
|
||||
/>
|
||||
<text
|
||||
bold={true}
|
||||
insert=" with"
|
||||
/>
|
||||
<text
|
||||
insert=" bold"
|
||||
/>
|
||||
</>
|
||||
}
|
||||
prop:type="text"
|
||||
/>
|
||||
</affine:page>
|
||||
`);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user