当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript UnitTest.asynctest方法代码示例

本文整理汇总了TypeScript中@ephox/bedrock.UnitTest.asynctest方法的典型用法代码示例。如果您正苦于以下问题:TypeScript UnitTest.asynctest方法的具体用法?TypeScript UnitTest.asynctest怎么用?TypeScript UnitTest.asynctest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@ephox/bedrock.UnitTest的用法示例。


在下文中一共展示了UnitTest.asynctest方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

import { Chain,  Keys,  Logger,  Pipeline } from '@ephox/agar';
import { Merger } from '@ephox/katamari';
import { ActionChains, ApiChains, Editor } from '@ephox/mcagar';
import Theme from 'tinymce/themes/silver/Theme';
import { UnitTest } from '@ephox/bedrock';

UnitTest.asynctest('browser.tinymce.core.keyboard.EnterKeyInlineTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];

  Theme();

  const settings = {
    base_url: '/project/tinymce/js/tinymce',
    inline: true
  };

  Pipeline.async({}, [
    Logger.t('Pressing shift+enter in brMode inside a h1 should insert a br', Chain.asStep({}, [
      Editor.cFromHtml('<h1>ab</h1>', Merger.merge(settings, { forced_root_block: false })),
      ApiChains.cFocus,
      ApiChains.cSetCursor([0], 1),
      ActionChains.cContentKeystroke(Keys.enter(), { shift: true }),
      ApiChains.cAssertContent('a<br />b'),
      Editor.cRemove
    ]))
  ], function () {
    success();
  }, failure);
});
开发者ID:tinymce,项目名称:tinymce,代码行数:30,代码来源:EnterKeyInlineTest.ts

示例2: Theme

UnitTest.asynctest('browser.tinymce.core.keyboard.ArrowKeysContentEndpointTest', (success, failure) => {
    Theme();

    TinyLoader.setup(function (editor, onSuccess, onFailure) {
      const tinyApis = TinyApis(editor);
      const tinyActions = TinyActions(editor);

      Pipeline.async({}, [
        tinyApis.sFocus,
        Logger.t('Arrow keys in figcaption', GeneralSteps.sequence([
          Logger.t('Arrow up from start of figcaption to paragraph before figure', GeneralSteps.sequence([
            tinyApis.sSetContent('<figure><figcaption>a</figcaption></figure>'),
            tinyApis.sSetCursor([0, 0, 0], 0),
            tinyActions.sContentKeystroke(Keys.up(), { }),
            tinyApis.sAssertContent('<p>&nbsp;</p><figure><figcaption>a</figcaption></figure>'),
            tinyApis.sAssertSelection([0], 0, [0], 0)
          ])),
          Logger.t('Arrow down from end of figcaption to paragraph after figure', GeneralSteps.sequence([
            tinyApis.sSetContent('<figure><figcaption>a</figcaption></figure>'),
            tinyApis.sSetCursor([0, 0, 0], 1),
            tinyActions.sContentKeystroke(Keys.down(), { }),
            tinyApis.sAssertContent('<figure><figcaption>a</figcaption></figure><p>&nbsp;</p>'),
            tinyApis.sAssertSelection([1], 0, [1], 0)
          ])),
          Logger.t('Arrow up in middle of figcaption', GeneralSteps.sequence([
            tinyApis.sSetContent('<figure><figcaption>ab</figcaption></figure>'),
            tinyApis.sSetCursor([0, 0, 0], 1),
            tinyActions.sContentKeystroke(Keys.up(), { }),
            tinyApis.sAssertContent('<p>&nbsp;</p><figure><figcaption>ab</figcaption></figure>'),
            tinyApis.sAssertSelection([0], 0, [0], 0)
          ])),
          Logger.t('Arrow down in middle of figcaption', GeneralSteps.sequence([
            tinyApis.sSetContent('<figure><figcaption>ab</figcaption></figure>'),
            tinyApis.sSetCursor([0, 0, 0], 1),
            tinyActions.sContentKeystroke(Keys.down(), { }),
            tinyApis.sAssertContent('<figure><figcaption>ab</figcaption></figure><p>&nbsp;</p>'),
            tinyApis.sAssertSelection([1], 0, [1], 0)
          ])),
          Logger.t('Arrow up at line 2 in figcaption should not insert new block', GeneralSteps.sequence([
            tinyApis.sSetContent('<figure><figcaption>a<br />b</figcaption></figure>'),
            tinyApis.sSetCursor([0, 0, 2], 0),
            tinyActions.sContentKeystroke(Keys.up(), { }),
            tinyApis.sAssertContent('<figure><figcaption>a<br />b</figcaption></figure>'),
            tinyApis.sAssertSelection([0, 0, 2], 0, [0, 0, 2], 0)
          ])),
          Logger.t('Arrow down at line 1 in figcaption should not insert new block', GeneralSteps.sequence([
            tinyApis.sSetContent('<figure><figcaption>a<br />b</figcaption></figure>'),
            tinyApis.sSetCursor([0, 0, 0], 1),
            tinyActions.sContentKeystroke(Keys.down(), { }),
            tinyApis.sAssertContent('<figure><figcaption>a<br />b</figcaption></figure>'),
            tinyApis.sAssertSelection([0, 0, 0], 1, [0, 0, 0], 1)
          ])),
          Logger.t('Arrow down at figcaption with forced_root_block_attrs set', GeneralSteps.sequence([
            tinyApis.sSetSetting('forced_root_block_attrs', { class: 'x' }),
            tinyApis.sSetContent('<figure><figcaption>a</figcaption></figure>'),
            tinyApis.sSetCursor([0, 0, 0], 1),
            tinyActions.sContentKeystroke(Keys.down(), { }),
            tinyApis.sAssertContent('<figure><figcaption>a</figcaption></figure><p class="x">&nbsp;</p>'),
            tinyApis.sAssertSelection([1], 0, [1], 0),
            tinyApis.sDeleteSetting('forced_root_block_attrs')
          ]))
        ]))
      ], onSuccess, onFailure);
    }, {
      add_unload_trigger: false,
      base_url: '/project/tinymce/js/tinymce',
      indent: false
    }, success, failure);
  }
);
开发者ID:tinymce,项目名称:tinymce,代码行数:70,代码来源:ArrowKeysContentEndpointTest.ts

示例3: function

UnitTest.asynctest('browser.tinymce.core.EditorUploadTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];
  const suite = LegacyUnit.createSuite();

  Theme();

  let testBlobDataUri;

  if (!Env.fileApi) {
    return;
  }

  const teardown = function (editor) {
    return Step.sync(function () {
      editor.editorUpload.destroy();
      editor.settings.automatic_uploads = false;
      delete editor.settings.images_replace_blob_uris;
      delete editor.settings.images_dataimg_filter;
    });
  };

  const appendTeardown = function (editor, steps) {
    return Arr.bind(steps, function (step) {
      return [step, teardown(editor)];
    });
  };

  const imageHtml = function (uri) {
    return DOMUtils.DOM.createHTML('img', { src: uri });
  };

  const assertResult = function (editor, uploadedBlobInfo, result) {
    LegacyUnit.strictEqual(result.length, 1);
    LegacyUnit.strictEqual(result[0].status, true);
    LegacyUnit.strictEqual(result[0].element.src.indexOf(uploadedBlobInfo.id() + '.png') !== -1, true);
    LegacyUnit.equal('<p><img src="' + uploadedBlobInfo.filename() + '" /></p>', editor.getContent());

    return result;
  };

  const hasBlobAsSource = function (elm) {
    return elm.src.indexOf('blob:') === 0;
  };

  suite.asyncTest('_scanForImages', function (editor, done, fail) {
    editor.setContent(imageHtml(testBlobDataUri));

    editor._scanForImages().then(function (result) {
      const blobInfo = result[0].blobInfo;

      LegacyUnit.equal('data:' + blobInfo.blob().type + ';base64,' + blobInfo.base64(), testBlobDataUri);
      LegacyUnit.equal(editor.getBody().innerHTML, '<p><img src="' + blobInfo.blobUri() + '"></p>');
      LegacyUnit.equal(
        '<p><img src="data:' + blobInfo.blob().type + ';base64,' + blobInfo.base64() + '" /></p>',
        editor.getContent()
      );
      LegacyUnit.strictEqual(editor.editorUpload.blobCache.get(blobInfo.id()), blobInfo);
    }).then(done).catch(fail);
  });

  suite.asyncTest('replace uploaded blob uri with result uri (copy/paste of an uploaded blob uri)', function (editor, done) {
    editor.setContent(imageHtml(testBlobDataUri));

    editor.settings.images_upload_handler = function (data, success) {
      success('file.png');
    };

    editor._scanForImages().then(function (result) {
      const blobUri = result[0].blobInfo.blobUri();

      editor.uploadImages(function () {
        editor.setContent(imageHtml(blobUri));
        LegacyUnit.strictEqual(hasBlobAsSource(editor.$('img')[0]), false);
        LegacyUnit.strictEqual(editor.getContent(), '<p><img src="file.png" /></p>');
        done();
      });
    });
  });

  suite.asyncTest(
  'don\'t replace uploaded blob uri with result uri (copy/paste of' +
  ' an uploaded blob uri) since blob uris are retained',
  function (editor, done) {
    editor.settings.images_replace_blob_uris = false;
    editor.setContent(imageHtml(testBlobDataUri));

    editor.settings.images_upload_handler = function (data, success) {
      success('file.png');
    };

    editor._scanForImages().then(function (result) {
      const blobUri = result[0].blobInfo.blobUri();

      editor.uploadImages(function () {
        editor.setContent(imageHtml(blobUri));
        LegacyUnit.strictEqual(hasBlobAsSource(editor.$('img')[0]), true);
        LegacyUnit.strictEqual(editor.getContent(), '<p><img src="file.png" /></p>');
        done();
      });
//.........这里部分代码省略.........
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:101,代码来源:EditorUploadTest.ts

示例4: function

UnitTest.asynctest('browser.tinymce.ui.FilePickerTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];
  const suite = LegacyUnit.createSuite();

  Theme();
  LinkPlugin();

  const getFilePickerCtrl = function (editor) {
    const win = editor.windowManager.getWindows()[0];
    return win ? win.find('filepicker')[0] : null;
  };

  const keydownOnCtrl = function (pickerCtrl, keyCode) {
    return new Promise(function (resolve) {
      pickerCtrl.fire('keydown', { target: pickerCtrl.getEl('inp'), keyCode });
      resolve(pickerCtrl);
    });
  };

  const downOnMenu = function (editor) {
    return function () {
      return keydownOnCtrl(getFilePickerCtrl(editor).menu, VK.DOWN);
    };
  };

  const enterOnMenu = function (editor) {
    return function () {
      return keydownOnCtrl(getFilePickerCtrl(editor).menu, VK.ENTER);
    };
  };

  const downOnPicker = function (editor) {
    return function () {
      return keydownOnCtrl(getFilePickerCtrl(editor), VK.DOWN);
    };
  };

  const enterOnPicker = function (editor) {
    return function () {
      return keydownOnCtrl(getFilePickerCtrl(editor), VK.ENTER);
    };
  };

  const setContent = function (editor, content) {
    return function () {
      return new Promise(function (resolve) {
        editor.setContent(content);
        resolve(true);
      });
    };
  };

  const execCommand = function (editor, cmd) {
    return function () {
      return new Promise(function (resolve) {
        editor.execCommand(cmd);
        resolve(true);
      });
    };
  };

  const assertContent = function (editor, exceptedContent) {
    return function () {
      return new Promise(function (resolve) {
        LegacyUnit.equal(editor.getContent(), exceptedContent, 'Should have the expected content');
        resolve(true);
      });
    };
  };

  const waitFor = function (predicate, poll, timeout) {
    return function () {
      const start = new Date().getTime();

      return new Promise(function (resolve, reject) {
        const check = function () {
          if (predicate()) {
            resolve();
            return;
          }

          if (new Date().getTime() - start > timeout) {
            reject(new Error('Timeout while waiting for predicate'));
            return;
          }

          window.setTimeout(check, poll);
        };

        check();
      });
    };
  };

  const waitForMenu = function (editor) {
    return waitFor(
      function () {
        const pickerCtrl = getFilePickerCtrl(editor);
        return pickerCtrl && pickerCtrl.menu;
//.........这里部分代码省略.........
开发者ID:abstask,项目名称:tinymce,代码行数:101,代码来源:FilePickerTest.ts

示例5: function

import Utils from '../module/test/Utils';

UnitTest.asynctest('browser.tinymce.plugins.media.DimensionsControlTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];

  Plugin();
  Theme();

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const ui = TinyUi(editor);

    Pipeline.async({}, [
      Utils.sOpenDialog(ui),
      ui.sClickOnUi('Click on close button', 'button:contains("Ok")'),
      Waiter.sTryUntil(
        'Wait for dialog to close',
        UiFinder.sNotExists(TinyDom.fromDom(document.body), 'div[aria-label="Insert/edit media"][role="dialog"]'),
        50, 5000
      )

    ], onSuccess, onFailure);
  }, {
    plugins: ['media'],
    toolbar: 'media',
    media_dimensions: false,
    skin_url: '/project/js/tinymce/skins/lightgray'
  }, success, failure);
});
开发者ID:abstask,项目名称:tinymce,代码行数:29,代码来源:DimensionsControlTest.ts

示例6: function

UnitTest.asynctest('browser.tinymce.plugins.codesample.CodeSampleSanityTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];

  CodePlugin();
  ModernTheme();

  const sInsertTextareaContent = function (value) {
    return Step.sync(function () {
      const textarea: any = document.querySelector('div[role="dialog"] textarea');
      textarea.value = value;
    });
  };

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyUi = TinyUi(editor);
    const tinyApis = TinyApis(editor);

    Pipeline.async({}, [
      tinyUi.sClickOnToolbar('click code button', 'div[aria-label="Insert/Edit code sample"] button'),
      tinyUi.sWaitForPopup('wait for window', 'div[role="dialog"]'),
      sInsertTextareaContent('<p>a</p>'),
      tinyUi.sClickOnUi('click OK btn', 'div.mce-primary button'),
      Waiter.sTryUntil('assert content',
        tinyApis.sAssertContentStructure(ApproxStructure.build(function (s, str) {
          return s.element('body', {
            children: [
              s.element('pre', {
                attrs: {
                  contenteditable: str.is('false')
                }
              }),
              s.anything()
            ]
          });
        })), 100, 3000)
    ], onSuccess, onFailure);
  }, {
    plugins: 'codesample',
    toolbar: 'codesample',
    skin_url: '/project/js/tinymce/skins/lightgray'
  }, success, failure);
});
开发者ID:abstask,项目名称:tinymce,代码行数:43,代码来源:CodeSampleSanityTest.ts

示例7: function

UnitTest.asynctest('browser.tinymce.plugins.tabfocus.TabfocusSanityTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];

  ModernTheme();
  TabfocusPlugin();

  const sAddInputs = function (editor) {
    return Step.sync(function () {
      const container = editor.getContainer();
      const input1 = document.createElement('input');
      input1.id = 'tempinput1';

      container.parentNode.insertBefore(input1, container);
    });
  };

  const sRemoveInputs = Step.sync(function () {
    const input1 = document.getElementById('tempinput1');

    input1.parentNode.removeChild(input1);
  });

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const tinyActions = TinyActions(editor);
    const tinyApis = TinyApis(editor);

    Pipeline.async({}, [
      sAddInputs(editor),
      tinyApis.sFocus,
      Step.sync(function () {
        RawAssertions.assertEq('should be same', 'IFRAME', document.activeElement.nodeName);
      }),
      tinyActions.sContentKeystroke(Keys.tab(), {}),
      Waiter.sTryUntil('vait for focus',
        Step.sync(function () {
          const input = document.getElementById('tempinput1');
          RawAssertions.assertEq('should be same', input.outerHTML, document.activeElement.outerHTML);
        }), 100, 4000),
      sRemoveInputs
    ], onSuccess, onFailure);
  }, {
    plugins: 'tabfocus',
    tabfocus_elements: 'tempinput1',
    skin_url: '/project/js/tinymce/skins/lightgray'
  }, success, failure);
});
开发者ID:danielpunkass,项目名称:tinymce,代码行数:47,代码来源:TabfocusSanityTest.ts

示例8: function

UnitTest.asynctest('browser.tinymce.core.EditorTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];
  const suite = LegacyUnit.createSuite();

  Theme();

  suite.test('Event: change', function (editor) {
    let level, lastLevel;

    editor.on('change', function (e) {
      level = e.level;
      lastLevel = e.lastLevel;
    });

    editor.setContent('');
    editor.insertContent('a');
    LegacyUnit.equal(level.content.toLowerCase(), '<p>a</p>');
    LegacyUnit.equal(lastLevel.content, editor.undoManager.data[0].content);

    editor.off('change');
  });

  suite.test('Event: beforeExecCommand', function (editor) {
    let cmd, ui, value;

    editor.on('BeforeExecCommand', function (e) {
      cmd = e.command;
      ui = e.ui;
      value = e.value;

      e.preventDefault();
    });

    editor.setContent('');
    editor.insertContent('a');
    LegacyUnit.equal(editor.getContent(), '');
    LegacyUnit.equal(cmd, 'mceInsertContent');
    LegacyUnit.equal(ui, false);
    LegacyUnit.equal(value, 'a');

    editor.off('BeforeExecCommand');
    editor.setContent('');
    editor.insertContent('a');
    LegacyUnit.equal(editor.getContent(), '<p>a</p>');
  });

  suite.test('urls - relativeURLs', function (editor) {
    editor.settings.relative_urls = true;
    editor.documentBaseURI = new URI('http://www.site.com/dirA/dirB/dirC/');

    editor.setContent('<a href="test.html">test</a>');
    LegacyUnit.equal(editor.getContent(), '<p><a href="test.html">test</a></p>');

    editor.setContent('<a href="../test.html">test</a>');
    LegacyUnit.equal(editor.getContent(), '<p><a href="../test.html">test</a></p>');

    editor.setContent('<a href="test/test.html">test</a>');
    LegacyUnit.equal(editor.getContent(), '<p><a href="test/test.html">test</a></p>');

    editor.setContent('<a href="/test.html">test</a>');
    LegacyUnit.equal(editor.getContent(), '<p><a href="../../../test.html">test</a></p>');

    editor.setContent('<a href="http://www.somesite.com/test/file.htm">test</a>');
    LegacyUnit.equal(editor.getContent(), '<p><a href="http://www.somesite.com/test/file.htm">test</a></p>');

    editor.setContent('<a href="//www.site.com/test/file.htm">test</a>');
    LegacyUnit.equal(editor.getContent(), '<p><a href="../../../test/file.htm">test</a></p>');

    editor.setContent('<a href="//www.somesite.com/test/file.htm">test</a>');
    LegacyUnit.equal(editor.getContent(), '<p><a href="//www.somesite.com/test/file.htm">test</a></p>');
  });

  suite.test('urls - absoluteURLs', function (editor) {
    editor.settings.relative_urls = false;
    editor.settings.remove_script_host = true;
    editor.documentBaseURI = new URI('http://www.site.com/dirA/dirB/dirC/');

    editor.setContent('<a href="test.html">test</a>');
    LegacyUnit.equal(editor.getContent(), '<p><a href="/dirA/dirB/dirC/test.html">test</a></p>');

    editor.setContent('<a href="../test.html">test</a>');
    LegacyUnit.equal(editor.getContent(), '<p><a href="/dirA/dirB/test.html">test</a></p>');

    editor.setContent('<a href="test/test.html">test</a>');
    LegacyUnit.equal(editor.getContent(), '<p><a href="/dirA/dirB/dirC/test/test.html">test</a></p>');

    editor.setContent('<a href="http://www.somesite.com/test/file.htm">test</a>');
    LegacyUnit.equal(editor.getContent(), '<p><a href="http://www.somesite.com/test/file.htm">test</a></p>');

    editor.settings.relative_urls = false;
    editor.settings.remove_script_host = false;

    editor.setContent('<a href="test.html">test</a>');
    LegacyUnit.equal(editor.getContent(), '<p><a href="http://www.site.com/dirA/dirB/dirC/test.html">test</a></p>');

    editor.setContent('<a href="../test.html">test</a>');
    LegacyUnit.equal(editor.getContent(), '<p><a href="http://www.site.com/dirA/dirB/test.html">test</a></p>');

    editor.setContent('<a href="test/test.html">test</a>');
//.........这里部分代码省略.........
开发者ID:tinymce,项目名称:tinymce,代码行数:101,代码来源:EditorTest.ts

示例9: function

UnitTest.asynctest('browser.core.EphoxEmbedTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];

  Plugin();
  Theme();

  const ephoxEmbedStructure = ApproxStructure.build(function (s, str/*, arr*/) {
    return s.element('p', {
      children: [
        s.element('div', {
          children: [
            s.element('iframe', {
              attrs: {
                src: str.is('about:blank')
              }
            })
          ],
          attrs: {
            'data-ephox-embed-iri': str.is('embed-iri'),
            'contenteditable': str.is('false')
          }
        })
      ]
    });
  });

  const sAssertDivStructure = function (editor, expected) {
    return Step.sync(function () {
      const div = editor.dom.select('div')[0];
      const actual = div ? Element.fromHtml(div.outerHTML) : Element.FromHtml('');
      return Assertions.sAssertStructure('Should be the same structure', expected, actual);
    });
  };

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const ui = TinyUi(editor);
    const apis = TinyApis(editor);

    Pipeline.async({}, [
      apis.sFocus,
      apis.sSetContent('<div contenteditable="false" data-ephox-embed-iri="embed-iri"><iframe src="about:blank"></iframe></div>'),
      sAssertDivStructure(editor, ephoxEmbedStructure),
      apis.sSelect('div', []),
      Utils.sOpenDialog(ui),
      Utils.sAssertSourceValue(ui, 'embed-iri'),
      Utils.sAssertEmbedContent(ui,
        '<div contenteditable="false" data-ephox-embed-iri="embed-iri">' +
        '<iframe src="about:blank"></iframe>' +
        '</div>'
      ),
      Utils.sSubmitDialog(ui),
      Waiter.sTryUntil('wait for div struture', sAssertDivStructure(editor, ephoxEmbedStructure), 100, 3000)
    ], onSuccess, onFailure);
  }, {
    plugins: 'media',
    toolbar: 'media',
    media_url_resolver (data, resolve) {
      resolve({
        html: '<video width="300" height="150" ' +
          'controls="controls">\n<source src="' + data.url + '" />\n</video>'
      });
    },
    skin_url: '/project/js/tinymce/skins/lightgray'
  }, success, failure);
});
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:66,代码来源:EphoxEmbedTest.ts

示例10: Theme

UnitTest.asynctest('browser.tinymce.core.annotate.AnnotateTest', (success, failure) => {
  Theme();

  TinyLoader.setup(function (editor: Editor, onSuccess, onFailure) {
    const tinyApis = TinyApis(editor);

    // TODO: Consider testing collapse sections.
    const sTestWordGrabIfCollapsed = Logger.t(
      'Should word grab with a collapsed selection',
      GeneralSteps.sequence([
        // '<p>This |is| the first paragraph</p><p>This is the second.</p>'
        tinyApis.sSetContent('<p>This is the first paragraph here</p><p>This is the second.</p>'),
        tinyApis.sSetSelection([ 0, 0 ], 'This is the first p'.length, [ 0, 0 ], 'This is the first p'.length),
        sAnnotate(editor, 'test-annotation', 'test-uid', { anything: 'one-paragraph' }),
        sAssertHtmlContent(tinyApis, [
          `<p>This is the first <span data-test-anything="one-paragraph" data-mce-annotation="test-annotation" data-mce-annotation-uid="test-uid" class="mce-annotation">paragraph</span> here</p>`,
          '<p>This is the second.</p'
        ]),

        tinyApis.sAssertSelection([ 0 ], 1, [ 0 ], 2)
      ])
    );

    const sTestCanAnnotateDirectParentOfRoot = Logger.t(
      'Should be able to annotate a direct parent of the body (e.g. an empty paragraph)',
      GeneralSteps.sequence([
        tinyApis.sSetContent('<p>First</p><p><br/></p><p>Third</p>'),
        tinyApis.sSetSelection([ 1 ], 0, [ 1 ], 0),
        sAnnotate(editor, 'test-annotation', 'test-uid', { anything: 'empty-paragraph' }),
        sAssertHtmlContent(tinyApis, [
          '<p>First</p>',
          '<p><span data-test-anything="empty-paragraph" data-mce-annotation="test-annotation" data-mce-annotation-uid="test-uid" class="mce-annotation"><br /></span></p>',
          '<p>Third</p>'
        ]),
      ])
    );

    const sTestCanAnnotateBeforeTwoNonBreakingSpaces = Logger.t(
      'Should annotate when the cursor is collapsed before two nbsps',
      GeneralSteps.sequence([
        tinyApis.sSetContent('<p>Annotation here &nbsp;&nbsp;, please</p>'),
        tinyApis.sSetCursor([ 0, 0 ], 'Annotation here '.length),
        sAnnotate(editor, 'test-annotation', 'test-uid', { anything: 'nbsp-paragraph' }),
        Assertions.sAssertStructure(
          'Checking body element',
          ApproxStructure.build((s, str, arr) => {
            return s.element('body', {
              children: [
                s.element('p', {
                  children: [
                    s.text( str.is('Annotation here ') ),
                    s.element('span', {
                      classes: [ arr.has('mce-annotation') ],
                      html: str.is('&nbsp;')
                    }),
                    s.text( str.is('\u00A0\u00A0, please'))
                  ]
                })
              ]
            });
          }),
          Element.fromDom(editor.getBody())
        )
      ])
    );

    const sTestCanAnnotateWithinTwoNonBreakingSpaces = Logger.t(
      'Should annotate when the cursor is collapsed between two nbsps',
      GeneralSteps.sequence([
        tinyApis.sSetContent('<p>Annotation here &nbsp;&nbsp;, please</p>'),
        tinyApis.sSetCursor([ 0, 0 ], 'Annotation here  '.length),
        sAnnotate(editor, 'test-annotation', 'test-uid', { anything: 'nbsp-paragraph' }),
        Assertions.sAssertStructure(
          'Checking body element',
          ApproxStructure.build((s, str, arr) => {
            return s.element('body', {
              children: [
                s.element('p', {
                  children: [
                    s.text( str.is('Annotation here \u00A0') ),
                    s.element('span', {
                      classes: [ arr.has('mce-annotation') ],
                      html: str.is('&nbsp;')
                    }),
                    s.text( str.is('\u00A0, please'))
                  ]
                })
              ]
            });
          }),
          Element.fromDom(editor.getBody())
        )
      ])
    );

    const sTestCanAnnotateAfterTwoNonBreakingSpaces = Logger.t(
      'Should annotate when the cursor is collapsed after two nbsps',
      GeneralSteps.sequence([
        tinyApis.sSetContent('<p>Annotation here &nbsp;&nbsp;, please</p>'),
        tinyApis.sSetCursor([ 0, 0 ], 'Annotation here   '.length),
//.........这里部分代码省略.........
开发者ID:tinymce,项目名称:tinymce,代码行数:101,代码来源:AnnotateTest.ts


注:本文中的@ephox/bedrock.UnitTest.asynctest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。