import { RawAssertions } from '@ephox/agar'; import FragmentParser from 'tinymce/plugins/paste/core/FragmentParser'; import { UnitTest } from '@ephox/bedrock'; UnitTest.test('atomic.tinymce.plugins.paste.FragmentParserTest', function () { const testGetFragmentInfo = function () { RawAssertions.assertEq( 'Should be the input string and context body', { html: 'abc', context: 'body' }, FragmentParser.getFragmentInfo('abc') ); RawAssertions.assertEq( 'Should be the input string without fragment markers and context body', { html: 'abc', context: 'body' }, FragmentParser.getFragmentInfo('abc') ); RawAssertions.assertEq( 'Should be the input string without fragment markers and context body', { html: 'abc', context: 'body' }, FragmentParser.getFragmentInfo('abc') ); RawAssertions.assertEq( 'Should be the input string without fragment markers and contents before/after fragment markers', { html: 'abc', context: 'body' }, FragmentParser.getFragmentInfo('XabcY') ); RawAssertions.assertEq( 'Should be the input string without fragment markers and contents before/after fragment markers', { html: 'boldabcThis', context: 'body' }, FragmentParser.getFragmentInfo('boldabcThis') ); RawAssertions.assertEq( 'Should be the input string without fragment markers and contents before/after them but with the ul context', { html: '
  • abc
  • ', context: 'ul' }, FragmentParser.getFragmentInfo('') ); RawAssertions.assertEq( 'Should be the input string without fragment markers and contents before/after them but with the ul context', { html: '\n
  • abc
  • \n', context: 'ul' }, FragmentParser.getFragmentInfo('\n\n') ); RawAssertions.assertEq( 'Should be the input string without fragment markers and contents before/after them but with the p context', { html: 'abc', context: 'p' }, FragmentParser.getFragmentInfo('

    abc

    ') ); RawAssertions.assertEq( 'Should be the input string without fragment markers and contents before/after them but with the h1 context', { html: 'abc', context: 'h1' }, FragmentParser.getFragmentInfo('

    abc

    ') ); }; const testGetFragmentHtml = function () { RawAssertions.assertEq( 'Should be the input string', 'abc', FragmentParser.getFragmentHtml('abc') ); RawAssertions.assertEq( 'Should be the input without fragment markers', 'abc', FragmentParser.getFragmentHtml('abc') ); RawAssertions.assertEq( 'Should be the input string without fragment markers', 'abc', FragmentParser.getFragmentHtml('abc') ); RawAssertions.assertEq( 'Should be the input string without fragment markers and suffix/prefix contents', 'abc', FragmentParser.getFragmentHtml('XabcY') ); RawAssertions.assertEq( 'Should be the input string without fragment markers and suffix/prefix contents', 'boldabcThis', FragmentParser.getFragmentHtml('boldabcThis') ); RawAssertions.assertEq( 'Should be the input string without fragment markers and suffix/prefix contents', '
  • abc
  • ', FragmentParser.getFragmentHtml('') ); RawAssertions.assertEq( 'Should be the input string without fragment markers and suffix/prefix contents', '\n
  • abc
  • \n', FragmentParser.getFragmentHtml('\n\n') ); RawAssertions.assertEq( 'Should be the input string with body element removed', '', FragmentParser.getFragmentHtml('') ); RawAssertions.assertEq( 'Should be the input string with body element removed', '', FragmentParser.getFragmentHtml('') ); RawAssertions.assertEq( 'Should be the input string with fragments and body element removed', '', FragmentParser.getFragmentHtml('') ); }; testGetFragmentInfo(); testGetFragmentHtml(); });