Logger.t('getStyleValue from image data', Step.sync(() => {
   RawAssertions.assertEq('Should not produce any styles', '', getStyleValue(normalizeCss, defaultData()));
   RawAssertions.assertEq('Should produce border width', 'border-width: 1px;', getStyleValue(normalizeCss, Merger.merge(defaultData(), { border: '1' })));
   RawAssertions.assertEq('Should produce style', 'border-style: solid;', getStyleValue(normalizeCss, Merger.merge(defaultData(), { borderStyle: 'solid' })));
   RawAssertions.assertEq('Should produce style & border', 'border-style: solid; border-width: 1px;', getStyleValue(normalizeCss, Merger.merge(defaultData(), { border: '1', borderStyle: 'solid' })));
   RawAssertions.assertEq('Should produce compact border', 'border: 2px dotted red;', getStyleValue(normalizeCss, Merger.merge(defaultData(), { style: 'border: 1px solid red', border: '2', borderStyle: 'dotted' })));
 })),
Exemple #2
0
 Logger.sync('getInfo ... ' + scenario.label + ', link: ' + scenario.linkHtml, function () {
   editorState.start.set(Element.fromHtml(scenario.linkHtml).dom());
   editorState.content.set(scenario.selection);
   const info = LinkBridge.getInfo(editor);
   RawAssertions.assertEq('Checking getInfo (link)', scenario.expected, Objects.narrow(info, [ 'url', 'text', 'target', 'title' ]));
   RawAssertions.assertEq('Checking link is set', true, info.link.isSome());
 });
UnitTest.test('Editor context menu settings test', () => {
  const userItems = Settings.getContextMenu(new Editor('id', { contextmenu: 'link image' }, EditorManager));
  RawAssertions.assertEq('Should pass user specified items though', ['link', 'image'], userItems);

  const editor = new Editor('id', { }, EditorManager);
  editor.ui.registry.addContextMenu('link', {
    update: () => []
  });
  const defaultItems = Settings.getContextMenu(editor);
  RawAssertions.assertEq('Should filter out non existing default items', ['link'], defaultItems);
});
Exemple #4
0
 Logger.sync('getInfo ... ' + scenario.label, function () {
   editorState.start.set(Element.fromText(scenario.nodeText).dom());
   editorState.content.set(scenario.selection);
   const info = LinkBridge.getInfo(editor);
   RawAssertions.assertEq('Checking getInfo (no link)', {
     url: '',
     text: scenario.expected,
     title: '',
     target: ''
   }, Objects.narrow(info, [ 'url', 'text', 'target', 'title' ]));
   RawAssertions.assertEq('Checking link is not set', true, info.link.isNone());
 });
UnitTest.test('atomic.tinymce.core.util.PredicateTest', () => {
  const isAbove = function (target, value) {
    return value() > target();
  };

  const isAbove5 = Fun.curry(isAbove, Fun.constant(5));
  const isAbove10 = Fun.curry(isAbove, Fun.constant(10));

  RawAssertions.assertEq('Should be extected and result', false, Predicate.and(isAbove10, isAbove5)(Fun.constant(10)));
  RawAssertions.assertEq('Should be extected and result', true, Predicate.and(isAbove10, isAbove5)(Fun.constant(30)));

  RawAssertions.assertEq('Should be extected or result', false, Predicate.or(isAbove10, isAbove5)(Fun.constant(5)));
  RawAssertions.assertEq('Should be extected or result', true, Predicate.or(isAbove10, isAbove5)(Fun.constant(15)));
  RawAssertions.assertEq('Should be extected or result', true, Predicate.or(isAbove5, isAbove10)(Fun.constant(15)));
});
Exemple #6
0
UnitTest.test('atomic.tinymce.plugins.visualchars.HtmlTest', function () {
  const nbsp = '\u00a0';
  const shy = '\u00AD';

  RawAssertions.assertEq(
    'should return correct span',
    '<span data-mce-bogus="1" class="mce-nbsp">' + nbsp + '</span>',
    Html.wrapCharWithSpan(nbsp)
  );

  RawAssertions.assertEq(
    'should return correct span',
    '<span data-mce-bogus="1" class="mce-shy">' + shy + '</span>',
    Html.wrapCharWithSpan(shy)
  );
});
    return Step.sync(function () {
      const elm = document.createElement('div');
      elm.innerHTML = inputHtml;
      TrimNode.trimNode(dom, elm.firstChild);

      const actual = elm.innerHTML;
      RawAssertions.assertEq('is correct trimmed html', expectedTrimmedHtml, actual);
    });
Exemple #8
0
  const testContentCss = (label: string, expectedContentCss: string[], inputContentCss: string[] | string | boolean) => {
    const editor = new Editor('id', {
      content_css: inputContentCss
    }, EditorManager);

    appendContentCssFromSettings(editor);

    RawAssertions.assertEq(label, expectedContentCss, editor.contentCSS);
  };
Exemple #9
0
UnitTest.test('atomic.tinymce.plugins.visualchars.DataTest', function () {
  RawAssertions.assertEq(
    'should return correst selector',
    'span.mce-a,span.mce-b',
    Data.charMapToSelector({ a: 'a', b: 'b' })
  );

  RawAssertions.assertEq(
    'should return correct regexp',
    '/[ab]/',
    Data.charMapToRegExp({ a: 'a', b: 'b' }).toString()
  );

  RawAssertions.assertEq(
    'should return correct global regexp',
    '/[ab]/g',
    Data.charMapToRegExp({ a: 'a', b: 'b' }, true).toString()
  );
});
Exemple #10
0
UnitTest.test('browser.tinymce.core.dom.TrimHtmlTest', function () {
  const serializer = DomSerializer({}, new Editor('id', {}, EditorManager));

  RawAssertions.assertEq('Should be unchanged', '<p id="a" data-mce-abc="1">a</p>', TrimHtml.trimInternal(serializer, '<p id="a" data-mce-abc="1">a</p>'));
  RawAssertions.assertEq('Should not have internal attr', '<p>a</p>', TrimHtml.trimInternal(serializer, '<p data-mce-selected="1">a</p>'));
  RawAssertions.assertEq('Should trim zwsp', '<p>ab</p>', TrimHtml.trimInternal(serializer, '<p>a' + Zwsp.ZWSP + 'b</p>'));

  RawAssertions.assertEq('Should be unchanged', '<p id="a" data-mce-abc="1">a</p>', TrimHtml.trimExternal(serializer, '<p id="a" data-mce-abc="1">a</p>'));
  RawAssertions.assertEq('Should not have internal attr', '<p>a</p>', TrimHtml.trimExternal(serializer, '<p data-mce-selected="1">a</p>'));
  RawAssertions.assertEq('Should not have zwsp', '<p>ab</p>', TrimHtml.trimExternal(serializer, '<p>a' + Zwsp.ZWSP + 'b</p>'));
});