diff --git a/test/data/alerts.ts b/test/data/alerts.ts index 3cee235e..c959b7ca 100644 --- a/test/data/alerts.ts +++ b/test/data/alerts.ts @@ -1,291 +1,319 @@ -const getTokens = (title: string) => { +const getTokens = (title: string, custom = false) => { return [ { - type: 'paragraph_open', - tag: 'p', attrs: null, - map: [0, 1], - nesting: 1, - level: 0, + block: true, children: null, content: '', - markup: '', + hidden: false, info: '', + level: 0, + map: [0, 1], + markup: '', meta: null, - block: true, - hidden: false, + nesting: 1, + tag: 'p', + type: 'paragraph_open', }, { - type: 'inline', - tag: '', attrs: null, - map: [0, 1], - nesting: 0, - level: 1, + block: true, children: [ { - type: 'text', - tag: '', attrs: null, - map: null, - nesting: 0, - level: 0, + block: false, children: null, content: 'Text before', - markup: '', + hidden: false, info: '', + level: 0, + map: null, + markup: '', meta: null, - block: false, - hidden: false, + nesting: 0, + tag: '', + type: 'text', }, ], content: 'Text before', - markup: '', + hidden: false, info: '', + level: 1, + map: [0, 1], + markup: '', meta: null, - block: true, - hidden: false, + nesting: 0, + tag: '', + type: 'inline', }, { - type: 'paragraph_close', - tag: 'p', attrs: null, - map: null, - nesting: -1, - level: 0, + block: true, children: null, content: '', - markup: '', + hidden: false, info: '', + level: 0, + map: null, + markup: '', meta: null, - block: true, - hidden: false, + nesting: -1, + tag: 'p', + type: 'paragraph_close', }, { - type: 'yfm_note_open', - tag: 'div', attrs: [ ['class', 'yfm-note yfm-accent-info'], ['note-type', 'info'], ], - map: [2, 3], - nesting: 1, - level: 0, + block: false, children: null, content: '', - markup: '', + hidden: false, info: '', + level: 0, + map: [2, 3], + markup: '', meta: null, - block: false, - hidden: false, + nesting: 1, + tag: 'div', + type: 'yfm_note_open', }, { - type: 'yfm_note_title_open', - tag: 'p', - attrs: [ - ['class', 'yfm-note-title'], - ...(title === 'Custom title' ? [['yfm2xliff-explicit', 'true']] : []), - ], - map: null, - nesting: 1, - level: 0, + attrs: [['class', 'yfm-note-title']].concat( + custom ? [['yfm2xliff-explicit', 'true']] : [], + ), + block: true, children: null, content: '', - markup: '', + hidden: false, info: '', + level: 0, + map: null, + markup: '', meta: null, - block: true, - hidden: false, + nesting: 1, + tag: 'p', + type: 'yfm_note_title_open', }, { - type: 'inline', - tag: '', attrs: null, - map: null, - nesting: 0, - level: 0, - children: - title === '' - ? [] - : [ - { - type: 'text', - tag: '', - attrs: null, - map: null, - nesting: 0, - level: 0, - children: null, - content: title, - markup: '', - info: '', - meta: null, - block: false, - hidden: false, - }, - ], + block: false, + children: title + ? [ + { + attrs: null, + block: false, + children: null, + content: title, + hidden: false, + info: '', + level: 0, + map: null, + markup: '', + meta: null, + nesting: 0, + tag: '', + type: 'text', + }, + ] + : [], content: title, - markup: '', + hidden: false, info: '', + level: 0, + map: null, + markup: '', meta: null, - block: false, - hidden: false, + nesting: 0, + tag: '', + type: 'inline', }, { - type: 'yfm_note_title_close', - tag: 'p', attrs: null, + block: true, + children: null, + content: '', + hidden: false, + info: '', + level: 0, map: null, + markup: '', + meta: null, nesting: -1, - level: 0, + tag: 'p', + type: 'yfm_note_title_close', + }, + { + attrs: [['class', 'yfm-note-content']], + block: false, children: null, content: '', - markup: '', + hidden: false, info: '', + level: 0, + map: [3, 4], + markup: '', meta: null, - block: true, - hidden: false, + nesting: 1, + tag: 'div', + type: 'yfm_note_content_open', }, { - type: 'paragraph_open', - tag: 'p', attrs: null, - map: [4, 5], - nesting: 1, - level: 0, + block: true, children: null, content: '', - markup: '', + hidden: false, info: '', + level: 0, + map: [4, 5], + markup: '', meta: null, - block: true, - hidden: false, + nesting: 1, + tag: 'p', + type: 'paragraph_open', }, { - type: 'inline', - tag: '', attrs: null, - map: [4, 5], - nesting: 0, - level: 1, + block: true, children: [ { - type: 'text', - tag: '', attrs: null, - map: null, - nesting: 0, - level: 0, + block: false, children: null, content: 'Текст примечания.', - markup: '', + hidden: false, info: '', + level: 0, + map: null, + markup: '', meta: null, - block: false, - hidden: false, + nesting: 0, + tag: '', + type: 'text', }, ], content: 'Текст примечания.', - markup: '', + hidden: false, info: '', + level: 1, + map: [4, 5], + markup: '', meta: null, - block: true, - hidden: false, + nesting: 0, + tag: '', + type: 'inline', }, { - type: 'paragraph_close', - tag: 'p', attrs: null, - map: null, - nesting: -1, - level: 0, + block: true, children: null, content: '', - markup: '', + hidden: false, info: '', + level: 0, + map: null, + markup: '', meta: null, - block: true, - hidden: false, + nesting: -1, + tag: 'p', + type: 'paragraph_close', }, { - type: 'yfm_note_close', - tag: 'div', attrs: null, - map: [6, 7], - nesting: -1, - level: 0, + block: false, children: null, content: '', - markup: '', + hidden: false, info: '', + level: 0, + map: null, + markup: '', meta: null, - block: false, - hidden: false, + nesting: -1, + tag: 'div', + type: 'yfm_note_content_close', }, { - type: 'paragraph_open', - tag: 'p', attrs: null, - map: [8, 9], - nesting: 1, - level: 0, + block: false, children: null, content: '', - markup: '', + hidden: false, info: '', + level: 0, + map: [6, 7], + markup: '', meta: null, + nesting: -1, + tag: 'div', + type: 'yfm_note_close', + }, + { + attrs: null, block: true, + children: null, + content: '', hidden: false, + info: '', + level: 0, + map: [8, 9], + markup: '', + meta: null, + nesting: 1, + tag: 'p', + type: 'paragraph_open', }, { - type: 'inline', - tag: '', attrs: null, - map: [8, 9], - nesting: 0, - level: 1, + block: true, children: [ { - type: 'text', - tag: '', attrs: null, - map: null, - nesting: 0, - level: 0, + block: false, children: null, content: 'Text after', - markup: '', + hidden: false, info: '', + level: 0, + map: null, + markup: '', meta: null, - block: false, - hidden: false, + nesting: 0, + tag: '', + type: 'text', }, ], content: 'Text after', - markup: '', + hidden: false, info: '', + level: 1, + map: [8, 9], + markup: '', meta: null, - block: true, - hidden: false, + nesting: 0, + tag: '', + type: 'inline', }, { - type: 'paragraph_close', - tag: 'p', attrs: null, - map: null, - nesting: -1, - level: 0, + block: true, children: null, content: '', - markup: '', + hidden: false, info: '', + level: 0, + map: null, + markup: '', meta: null, - block: true, - hidden: false, + nesting: -1, + tag: 'p', + type: 'paragraph_close', }, ]; }; export const base = getTokens('Примечание'); -export const customTitle = getTokens('Custom title'); +export const customTitle = getTokens('Custom title', true); export const emptyTitle = getTokens(''); diff --git a/test/notes.test.ts b/test/notes.test.ts index 83a529ed..fb062625 100644 --- a/test/notes.test.ts +++ b/test/notes.test.ts @@ -97,8 +97,8 @@ describe('Alerts', () => { ), ).toBe( '

Note title

\n' + - '

Note content

\n' + - '
', + '

Note content

\n' + + '
', ); }); @@ -119,10 +119,10 @@ describe('Alerts', () => { ), ).toBe( '

Note title 1

\n' + - '

Note content 1

\n' + - '

Note title 2

\n' + - '

Note content 2

\n' + - '
', + '

Note content 1

\n' + + '

Note title 2

\n' + + '

Note content 2

\n' + + '
', ); }); @@ -143,10 +143,10 @@ describe('Alerts', () => { ), ).toBe( '

Outer title

\n' + - '

Outer content

\n' + + '

Outer content

\n' + '

Inner title

\n' + - '

Inner content

\n' + - '
', + '

Inner content

\n' + + '
', ); }); @@ -162,8 +162,8 @@ describe('Alerts', () => { ).toBe( '
' + '

Italic note title

\n' + - '

Content

\n' + - '
', + '

Content

\n' + + '
', ); }); });