import { afterEach, describe, it } from '@ephox/bedrock-client'; import { TinyAssertions, TinyHooks, TinySelections } from '@ephox/wrap-mcagar'; import Editor from 'tinymce/core/api/Editor'; import Plugin from 'tinymce/plugins/template/Plugin'; import { pInsertTemplate } from '../module/InsertTemplate'; import { Settings } from '../module/Settings'; describe('browser.tinymce.plugins.template.DatesTest', () => { const hook = TinyHooks.bddSetupLight({ plugins: 'template', toolbar: 'template', base_url: '/project/tinymce/js/tinymce' }, [ Plugin ]); const { addSettings, cleanupSettings } = Settings(hook); afterEach(() => { const editor = hook.editor(); cleanupSettings(); editor.setContent(''); }); it('TBA: Test cdate in snippet with default class', async () => { const editor = hook.editor(); addSettings({ templates: [{ title: 'a', description: 'b', content: '

x

' }], template_cdate_format: 'fake date', }); await pInsertTemplate(editor); TinyAssertions.assertContent(editor, '

fake date

'); }); it('TBA: Test cdate in snippet with custom class', async () => { const editor = hook.editor(); addSettings({ template_cdate_classes: 'customCdateClass', templates: [{ title: 'a', description: 'b', content: '

x

' }], template_cdate_format: 'fake date' }); await pInsertTemplate(editor); TinyAssertions.assertContent(editor, '

fake date

' ); }); it('TBA: Test mdate updates with each serialization', async () => { const editor = hook.editor(); addSettings({ template_mdate_format: 'fake modified date', template_cdate_format: 'fake created date', templates: [{ title: 'a', description: 'b', content: '

' }] }); await pInsertTemplate(editor); TinyAssertions.assertContent(editor, [ '
', '

fake modified date

', '

fake created date

', '
' ].join('\n')); addSettings({ template_mdate_format: 'changed modified date' }); TinyAssertions.assertContent(editor, [ '
', '

changed modified date

', '

fake created date

', '
' ].join('\n')); }); it('TBA: Test mdate updates with each serialization with custom class', async () => { const editor = hook.editor(); addSettings({ template_mdate_classes: 'modified', template_mdate_format: 'fake modified date', template_cdate_format: 'fake created date', templates: [{ title: 'a', description: 'b', content: '

' }] }); await pInsertTemplate(editor); TinyAssertions.assertContent(editor, [ '
', '

fake modified date

', '

fake created date

', '
' ].join('\n')); addSettings({ template_mdate_format: 'changed modified date' }); TinyAssertions.assertContent(editor, [ '
', '

changed modified date

', '

fake created date

', '
' ].join('\n')); }); it('TBA: Multiple replacement classes provided via options', async () => { const editor = hook.editor(); addSettings({ templates: [{ title: 'a', description: 'b', content: '

x

y

' }], template_cdate_classes: 'cdate1 cdate2', template_cdate_format: 'fake created date', template_mdate_classes: 'mdate1 mdate2', template_mdate_format: 'fake modified date', }); await pInsertTemplate(editor); TinyAssertions.assertContent(editor, [ '
', '

fake created date

', '

fake modified date

', '
' ].join('\n')); TinySelections.setCursor(editor, [ 0, 1, 0 ], 'fake modified date'.length); editor.insertContent('

inserted modified date

'); addSettings({ template_mdate_format: 'changed modified date' }); TinyAssertions.assertContent(editor, [ '
', '

fake created date

', '

changed modified date

', '

changed modified date

', '
' ].join('\n')); }); it('TINY-7433: replacement classes with regex like names', async () => { const editor = hook.editor(); addSettings({ templates: [{ title: 'a', description: 'b', content: '

x

y

' }], template_cdate_classes: 'custom+cdate', template_cdate_format: 'fake created date', template_mdate_classes: 'custom+mdate', template_mdate_format: 'fake modified date', }); await pInsertTemplate(editor); TinyAssertions.assertContent(editor, [ '
', '

fake created date

', '

fake modified date

', '
' ].join('\n')); }); });