• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript agar.ApproxStructure类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@ephox/agar.ApproxStructure的典型用法代码示例。如果您正苦于以下问题:TypeScript ApproxStructure类的具体用法?TypeScript ApproxStructure怎么用?TypeScript ApproxStructure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: TestExtras

UnitTest.asynctest('WindowManager:simple-dialog Test', (success, failure) => {
  const helpers = TestExtras();
  const windowManager = WindowManager.setup(helpers.extras);

  const currentApi = Cell<Types.Dialog.DialogInstanceApi<any>>({ } as any);

  const store = TestHelpers.TestStore();

  const sTestOpen = Chain.asStep({ }, [
    Chain.mapper((_) => {
      return windowManager.open({
        title: 'Silver Test Modal Dialog',
        body: {
          type: 'panel',
          items: [
            {
              type: 'input',
              name: 'fred',
              label: 'Freds Input'
            },
          ]
        },
        buttons: [
          {
            type: 'custom',
            name: 'barny',
            text: 'Barny Text',
            align: 'start',
            primary: true
          },
        ],
        initialData: {
          fred: 'said hello pebbles'
        },
        onSubmit: store.adder('onSubmit'),
        onClose: store.adder('onClose'),
        onChange: store.adder('onChange'),
        onAction: store.adder('onAction')
      }, {}, () => store.adder('closeWindow')());
    }),

    Chain.op((dialogApi) => {
      Assertions.assertEq('Initial data', {
        fred: 'said hello pebbles'
      }, dialogApi.getData());

      currentApi.set(dialogApi);
    })
  ]);

  const sTestClose = GeneralSteps.sequence([
    Mouse.sClickOn(Body.body(), '[aria-label="Close"]'),
    UiFinder.sNotExists(Body.body(), '[role="dialog"]')
  ]);

  Pipeline.async({}, [
    sTestOpen,
    FocusTools.sTryOnSelector(
      'Focus should start on the input',
      Element.fromDom(document),
      'input'
    ),
    Assertions.sAssertStructure('"tox-dialog__scroll-disable" should exist on the body',
      ApproxStructure.build((s, str, arr) => {
        return s.element('body', {
          classes: [ arr.has('tox-dialog__disable-scroll') ]
        });
      }),
      Body.body()
    ),
    Step.sync(() => {
      currentApi.get().disable('barny');
    }),
    sTestClose,
    Waiter.sTryUntil(
      'Waiting for all dialog events when closing',
      store.sAssertEq('Checking stuff', [
        'closeWindow',
        'onClose',
      ]),
      100,
      3000
    ),
    Assertions.sAssertStructure('"tox-dialog__scroll-disable" should have been removed from the body',
      ApproxStructure.build((s, str, arr) => {
        return s.element('body', {
          classes: [ arr.not('tox-dialog__disable-scroll') ]
        });
      }),
      Body.body()
    ),
  ], () => {
    helpers.destroy();
    success();
  }, failure);
});
开发者ID:tinymce,项目名称:tinymce,代码行数:96,代码来源:SilverDialogTest.ts


示例2:

 const caret = (type: string) => {
   return ApproxStructure.fromHtml(`<p data-mce-caret="${type}" data-mce-bogus="all"><br data-mce-bogus="1"></p>`);
 };
开发者ID:,项目名称:,代码行数:3,代码来源:


示例3: catch

      Step.sync(function () {
        const conf: Types.Dialog.DialogApi<any> = {
          title: 'test',
          body: {
            type: 'panel',
            items: [
              {
                name: 'fooname',
                type: 'input',
                label: 'Foo Label'
              },
            ]
          },
          buttons: [],
          initialData: {
            fooname: 'hello world'
          }
        };

        const instanceApi = windowManager.open(conf, {}, Fun.noop);
        const dialogBody = SugarElement.fromDom(document.querySelector('.tox-dialog__body'));

        Assertions.assertStructure('It should load with form components in the dom structure',
          ApproxStructure.build((s, str, arr) => {
            return s.element('div', {
              classes: [ arr.has('tox-dialog__body') ],
              children: [
                s.element('div', {
                  classes: [ arr.has('tox-dialog__body-content') ],
                  children: [
                    s.element('div', {
                      classes: [ arr.has('tox-form') ],
                      children: [
                        s.element('div', {
                          classes: [ arr.has('tox-form__group') ],
                          children: [
                            s.element('label', {
                              classes: [ arr.has('tox-label') ],
                              attrs: {
                                for: str.startsWith( 'form-field_' )
                              },
                              html: str.is('Foo Label')
                            }),
                            s.element('input', {
                              classes: [ arr.has('tox-textfield') ],
                              attrs: {
                                type: str.is('text')
                              }
                            })
                          ]
                        })
                      ]
                    })
                  ]
                })
              ]
            });
          }),
          dialogBody
        );

        const inputElement: HTMLInputElement = document.querySelector('input.tox-textfield');
        Assertions.assertEq('The input value should equal the initial data', conf.initialData.fooname, inputElement.value);

        const nuData = { fooname: 'Bonjour Universe' };
        instanceApi.setData(nuData);
        Assertions.assertEq('Calling setData, should update the data', nuData, instanceApi.getData());

        const badData = { fooname: [ 'not right' ] };

        try {
          instanceApi.setData(badData);
        } catch (error) {
          const message = error.message.split('\n');
          Assertions.assertEq('Calling setData, with invalid data should throw: ', message[1], 'Failed path: (data > fooname)');
          Assertions.assertEq('Calling setData, with invalid data should throw: ', message[2], 'Expected type: string but got: object');
        }
        Assertions.assertEq('Calling setData, with invalid data, should not change the data, it should remain the same', nuData, instanceApi.getData());

      }),
开发者ID:tinymce,项目名称:tinymce,代码行数:80,代码来源:WindowManagerTest.ts


示例4: function

UnitTest.asynctest('Browser Test: ui.SerialisedLinkTest', function () {
  const success = arguments[arguments.length - 2];
  const failure = arguments[arguments.length - 1];
  const detection = PlatformDetection.detect();

  const realm = IosRealm(Fun.noop);
  // Make toolbar appear
  Class.add(realm.system().element(), 'tinymce-mobile-fullscreen-maximized');

  const body = Body.body();
  Attachment.attachSystem(body, realm.system());

  const doc = Traverse.owner(body);

  TestStyles.addStyles();

  const unload = function () {
    TestStyles.removeStyles();
    Attachment.detachSystem(realm.system());
  };

  const tEditor = TestEditor();

  realm.setToolbarGroups([
    {
      label: 'group1',
      items: [
        LinkButton.sketch(realm, tEditor.editor())
      ]
    }
  ]);

  const sAssertNavigation = function (label, prevEnabled, nextEnabled) {
    return Logger.t(
      label,
      Step.sync(function () {
        const active = Focus.active().getOrDie();
        // The buttons are next and previous siblings
        const prev = Traverse.parent(active).bind(Traverse.prevSibling).getOrDie('Could not find button to left');
        const next = Traverse.parent(active).bind(Traverse.nextSibling).getOrDie('Could not find button to right');

        const assertNavButton = function (buttonLabel, expected, button) {
          Assertions.assertStructure(
            'Checking ' + buttonLabel + ' button should be enabled = ' + expected,
            ApproxStructure.build(function (s, str, arr) {
              return s.element('span', {
                attrs: {
                  role: str.is('button')
                },
                classes: [
                  (expected ? arr.not : arr.has)('tinymce-mobile-toolbar-navigation-disabled')
                ]
              });
            }),
            button
          );
        };

        assertNavButton('previous', prevEnabled, prev);
        assertNavButton('next', nextEnabled, next);
      })
    );
  };

  const sClickNavigation = function (selector) {
    return Chain.asStep({ }, [
      TestUi.cGetFocused,
      TestUi.cGetParent,
      TestUi.cGetParent,
      UiFinder.cFindIn(selector),
      Mouse.cClick
    ]);
  };

  const sClickPrev = sClickNavigation('.tinymce-mobile-icon-previous');
  const sClickNext = sClickNavigation('.tinymce-mobile-icon-next');

  const sAssertUrlFocused = GeneralSteps.sequence([
    FocusTools.sTryOnSelector('Focus should be on input with link URL', doc, 'input[placeholder="Type or paste URL"]'),
    sAssertNavigation('Checking initial navigation on text node', false, true)
  ]);

  const sAssertTextFocused = GeneralSteps.sequence([
    FocusTools.sTryOnSelector('Focus should be on input with link text', doc, 'input[placeholder="Link text"]'),
    sAssertNavigation('Checking navigation for link text', true, true)
  ]);

  const sAssertTitleFocused = GeneralSteps.sequence([
    FocusTools.sTryOnSelector('Focus should be on input with link title', doc, 'input[placeholder="Link title"]'),
    sAssertNavigation('Checking navigation for link title', true, true)
  ]);

  const sAssertTargetFocused = GeneralSteps.sequence([
    FocusTools.sTryOnSelector('Focus should be on input with link target', doc, 'input[placeholder="Link target"]'),
    sAssertNavigation('Checking navigation for link target', true, false)
  ]);

  const sTestNavigation = GeneralSteps.sequence([
    Keyboard.sKeydown(doc, Keys.tab(), { }),
    sAssertTextFocused,
//.........这里部分代码省略.........
开发者ID:danielpunkass,项目名称:tinymce,代码行数:101,代码来源:SerialisedLinkTest.ts


示例5: function

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

  Plugin();
  Theme();

  const sTestPlaceholder = function (ui, editor, apis, url, expected, struct) {
    return GeneralSteps.sequence([
      Utils.sOpenDialog(ui),
      Utils.sSetFormItemNoEvent(ui, url),
      ui.sClickOnUi('click checkbox', 'div.mce-primary > button'),
      Utils.sAssertEditorContent(apis, editor, expected),
      Waiter.sTryUntil('Wait for structure check',
        apis.sAssertContentStructure(struct),
        100, 3000),
      apis.sSetContent('')
    ]);
  };

  const sTestScriptPlaceholder = function (ui, editor, apis, expected, struct) {
    return GeneralSteps.sequence([
      apis.sSetContent(
        '<script src="http://media1.tinymce.com/123456"></script>' +
        '<script src="http://media2.tinymce.com/123456"></script>'),
      apis.sNodeChanged,
      Waiter.sTryUntil('Wait for structure check',
        apis.sAssertContentStructure(struct),
        10, 500),
      Utils.sAssertEditorContent(apis, editor, expected),
      apis.sSetContent('')
    ]);
  };
  const placeholderStructure = ApproxStructure.build(function (s) {
    return s.element('body', {
      children: [
        s.element('p', {
          children: [
            s.element('img', {})
          ]
        }),
        s.element('div', {}),
        s.element('div', {}),
        s.element('div', {}),
        s.element('div', {})
      ]
    });
  });

  const iframeStructure = ApproxStructure.build(function (s) {
    return s.element('body', {
      children: [
        s.element('p', {
          children: [
            s.element('span', {
              children: [
                s.element('iframe', {}),
                s.element('span', {})
              ]
            }),
            s.anything()
          ]
        })
      ]
    });
  });

  const scriptStruct = ApproxStructure.build(function (s, str, arr) {
    return s.element('body', {
      children: [
        s.element('p', {
          children: [
            s.element('img', {
              classes: [
                arr.has('mce-object'),
                arr.has('mce-object-script')
              ],
              attrs: {
                height: str.is('150'),
                width: str.is('300')
              }
            }),
            s.element('img', {
              classes: [
                arr.has('mce-object'),
                arr.has('mce-object-script')
              ],
              attrs: {
                height: str.is('200'),
                width: str.is('100')
              }
            })
          ]
        })
      ]
    });
  });

  TinyLoader.setup(function (editor, onSuccess, onFailure) {
    const ui = TinyUi(editor);
//.........这里部分代码省略.........
开发者ID:danielpunkass,项目名称:tinymce,代码行数:101,代码来源:PlaceholderTest.ts


示例6: TinyApis

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

    Pipeline.async({}, [
      tinyApis.sFocus,
      Logger.t('Backspace on collapsed range should be a noop', GeneralSteps.sequence([
        tinyApis.sSetContent('<p>a</p>'),
        tinyApis.sSetCursor([0, 0], 1),
        sBackspaceNoop(editor),
        tinyApis.sAssertContent('<p>a</p>'),
        tinyApis.sAssertSelection([0, 0], 1, [0, 0], 1)
      ])),
      Logger.t('Delete on collapsed range should be a noop', GeneralSteps.sequence([
        tinyApis.sSetContent('<p>a</p>'),
        tinyApis.sSetCursor([0, 0], 1),
        sDeleteNoop(editor),
        tinyApis.sAssertContent('<p>a</p>'),
        tinyApis.sAssertSelection([0, 0], 1, [0, 0], 1)
      ])),
      Logger.t('Backspace on range between simple blocks should merge', GeneralSteps.sequence([
        tinyApis.sSetContent('<p>a</p><p>b</p>'),
        tinyApis.sSetSelection([0, 0], 1, [1, 0], 0),
        sBackspace(editor),
        tinyApis.sAssertContent('<p>ab</p>'),
        tinyApis.sAssertSelection([0, 0], 1, [0, 0], 1)
      ])),
      Logger.t('Delete on range between simple blocks should merge', GeneralSteps.sequence([
        tinyApis.sSetContent('<p>a</p><p>b</p>'),
        tinyApis.sSetSelection([0, 0], 1, [1, 0], 0),
        sDelete(editor),
        tinyApis.sAssertContent('<p>ab</p>'),
        tinyApis.sAssertSelection([0, 0], 1, [0, 0], 1)
      ])),
      Logger.t('Backspace from red span to h1 should merge', GeneralSteps.sequence([
        tinyApis.sSetContent('<h1>ab</h1><p><span style="color: red;">cd</span></p>'),
        tinyApis.sSetSelection([0, 0], 1, [1, 0, 0], 1),
        sBackspace(editor),
        tinyApis.sAssertContent('<h1>a<span style="color: red;">d</span></h1>'),
        tinyApis.sAssertSelection([0, 0], 1, [0, 0], 1)
      ])),
      Logger.t('Delete from red span to h1 should merge', GeneralSteps.sequence([
        tinyApis.sSetContent('<p><span style="color: red;">ab</span></p><h1>cd</h1>'),
        tinyApis.sSetSelection([0, 0, 0], 1, [1, 0], 1),
        sDelete(editor),
        tinyApis.sAssertContent('<p><span style="color: red;">a</span>d</p>'),
        tinyApis.sAssertSelection([0, 0, 0], 1, [0, 0, 0], 1)
      ])),
      Logger.t('Delete from li to li should merge', GeneralSteps.sequence([
        tinyApis.sSetContent('<ul><li>ab</li><li>cd</li></ul>'),
        tinyApis.sSetSelection([0, 0, 0], 1, [0, 1, 0], 1),
        sDelete(editor),
        tinyApis.sAssertContent('<ul><li>ad</li></ul>'),
        tinyApis.sAssertSelection([0, 0, 0], 1, [0, 0, 0], 1)
      ])),
      Logger.t('Delete from nested li to li should merge', GeneralSteps.sequence([
        tinyApis.sSetContent('<ul><li>ab<ul><li>cd</li></ul></li></ul>'),
        tinyApis.sSetSelection([0, 0, 0], 1, [0, 0, 1, 0, 0], 1),
        sDelete(editor),
        tinyApis.sAssertContent('<ul><li>ad</li></ul>'),
        tinyApis.sAssertSelection([0, 0, 0], 1, [0, 0, 0], 1)
      ])),
      Logger.t('Delete from li to nested li should merge', GeneralSteps.sequence([
        tinyApis.sSetContent('<ul><li>ab<ul><li>cd</li></ul></li><li>ef</li></ul>'),
        tinyApis.sSetSelection([0, 0, 1, 0, 0], 1, [0, 1, 0], 1),
        sDelete(editor),
        tinyApis.sAssertContent('<ul><li>ab<ul><li>cf</li></ul></li></ul>'),
        tinyApis.sAssertSelection([0, 0, 1, 0, 0], 1, [0, 0, 1, 0, 0], 1)
      ])),
      Logger.t('Delete from deep nested li to li should merge', GeneralSteps.sequence([
        tinyApis.sSetContent('<ul><li>ab<ul><li>cd<ul><li>ef</li></li></ul></li></ul>'),
        tinyApis.sSetSelection([0, 0, 0], 1, [0, 0, 1, 0, 1, 0, 0], 1),
        sDelete(editor),
        tinyApis.sAssertContent('<ul><li>af</li></ul>'),
        tinyApis.sAssertSelection([0, 0, 0], 1, [0, 0, 0], 1)
      ])),
      Logger.t('Delete on selection of everything should empty editor', GeneralSteps.sequence([
        tinyApis.sSetContent('<p>a</p><p>b</p>'),
        tinyApis.sSetSelection([0, 0], 0, [1, 0], 1),
        sDelete(editor),
        tinyApis.sAssertContent(''),
        tinyApis.sAssertSelection([0], 0, [0], 0),
        tinyApis.sAssertContentStructure(ApproxStructure.build(function (s, str) {
          return s.element('body', {
            children: [
              s.element('p', { children: [ s.element('br', { attrs: { 'data-mce-bogus': str.is('1') } }) ] })
            ]
          });
        }))
      ])),
      Logger.t('Backspace selected paragraphs in td should produce an padded empty cell and also not delete the whole table', GeneralSteps.sequence([
        tinyApis.sSetContent('<table><tbody><tr><td><p>a</p><p>b</p></td></tr></tbody></table>'),
        tinyApis.sSetSelection([0, 0, 0, 0, 0, 0], 0, [0, 0, 0, 0, 1, 0], 1),
        sBackspace(editor),
        tinyApis.sAssertContent('<table><tbody><tr><td><p>&nbsp;</p></td></tr></tbody></table>'),
        tinyApis.sAssertSelection([0, 0, 0, 0, 0], 0, [0, 0, 0, 0, 0], 0)
      ])),
      Logger.t('Delete selected paragraphs in td should produce an padded empty cell and also not delete the whole table', GeneralSteps.sequence([
        tinyApis.sSetContent('<table><tbody><tr><td><p>a</p><p>b</p></td></tr></tbody></table>'),
        tinyApis.sSetSelection([0, 0, 0, 0, 0, 0], 0, [0, 0, 0, 0, 1, 0], 1),
        sDelete(editor),
//.........这里部分代码省略.........
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:101,代码来源:BlockRangeDeleteTest.ts


示例7: TinyApis

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

    Pipeline.async({}, [
      tinyApis.sFocus,
      Logger.t('Backspace/delete in unformatted plain text', GeneralSteps.sequence([
        Logger.t('Backspace after plain text should do nothing', GeneralSteps.sequence([
          tinyApis.sSetContent('<p>a</p>'),
          tinyApis.sSetCursor([0, 0], 1),
          sBackspaceNoop(editor),
          tinyApis.sAssertContent('<p>a</p>'),
          tinyApis.sAssertSelection([0, 0], 1, [0, 0], 1)
        ])),
        Logger.t('Delete before plain text should do nothing', GeneralSteps.sequence([
          tinyApis.sSetContent('<p>a</p>'),
          tinyApis.sSetCursor([0, 0], 0),
          sDeleteNoop(editor),
          tinyApis.sAssertContent('<p>a</p>'),
          tinyApis.sAssertSelection([0, 0], 0, [0, 0], 0)
        ])),
        Logger.t('Backspace in middle of plain text should do nothing', GeneralSteps.sequence([
          tinyApis.sSetContent('<p>ab</p>'),
          tinyApis.sSetCursor([0, 0], 1),
          sBackspaceNoop(editor),
          tinyApis.sAssertContent('<p>ab</p>'),
          tinyApis.sAssertSelection([0, 0], 1, [0, 0], 1)
        ])),
        Logger.t('Delete in middle of plain text should do nothing', GeneralSteps.sequence([
          tinyApis.sSetContent('<p>ab</p>'),
          tinyApis.sSetCursor([0, 0], 1),
          sDeleteNoop(editor),
          tinyApis.sAssertContent('<p>ab</p>'),
          tinyApis.sAssertSelection([0, 0], 1, [0, 0], 1)
        ])),
        Logger.t('Delete in middle of caret format span should do nothing', GeneralSteps.sequence([
          tinyApis.sSetRawContent('<p>a<span id="_mce_caret" data-mce-bogus="1" data-mce-type="format-caret"><strong>&#65279;</strong></span>b</p>'),
          tinyApis.sSetCursor([0, 1], 0),
          sDeleteNoop(editor),
          tinyApis.sAssertSelection([0, 1], 0, [0, 1], 0),
          tinyApis.sAssertContentStructure(
            ApproxStructure.build(function (s, str, arr) {
              return s.element('body', {
                children: [
                  s.element('p', {
                    children: [
                      s.text(str.is('a')),
                      s.element('span', {
                        attrs: {
                          'id': str.is('_mce_caret'),
                          'data-mce-bogus': str.is('1')
                        },
                        children: [
                          s.element('strong', {
                            children: [
                              s.text(str.is(Zwsp.ZWSP))
                            ]
                          })
                        ]
                      }),
                      s.text(str.is('b')),
                    ]
                  })
                ]
              });
            })
          )
        ]))
      ])),
      Logger.t('Backspace/delete in at last character', GeneralSteps.sequence([
        Logger.t('Backspace after last character in formatted element', GeneralSteps.sequence([
          tinyApis.sSetContent('<p><strong><em>a</em></strong></p>'),
          tinyApis.sSetCursor([0, 0, 0, 0], 1),
          sBackspace(editor),
          tinyApis.sAssertContentStructure(
            ApproxStructure.build(function (s, str, arr) {
              return s.element('body', {
                children: [
                  s.element('p', {
                    children: [
                      s.element('span', {
                        attrs: {
                          'id': str.is('_mce_caret'),
                          'data-mce-bogus': str.is('1')
                        },
                        children: [
                          s.element('strong', {
                            children: [
                              s.element('em', {
                                children: [
                                  s.text(str.is(Zwsp.ZWSP))
                                ]
                              })
                            ]
                          })
                        ]
                      })
                    ]
                  })
                ]
              });
//.........这里部分代码省略.........
开发者ID:danielpunkass,项目名称:tinymce,代码行数:101,代码来源:InlineFormatDeleteTest.ts


示例8: 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:abstask,项目名称:tinymce,代码行数:66,代码来源:EphoxEmbedTest.ts


示例9: TestExtras

UnitTest.asynctest('WindowManager:url-dialog Test', (success, failure) => {
  const helpers = TestExtras();
  const windowManager = WindowManager.setup(helpers.extras);

  const currentApi = Cell<Types.UrlDialog.UrlDialogInstanceApi>({ } as any);

  const store = TestHelpers.TestStore();

  const sTestOpen = Chain.asStep({ }, [
    Chain.mapper((_) => {
      return windowManager.openUrl({
        title: 'Silver Test Modal URL Dialog',
        url: '/project/tinymce/src/themes/silver/test/html/iframe.html',
        buttons: [
          {
            type: 'custom',
            name: 'barny',
            text: 'Barny Text',
            align: 'start',
            primary: true
          },
        ],
        onClose: store.adder('onClose'),
        onAction: store.adder('onAction'),
        onMessage: store.adder('onMessage')
      }, () => store.adder('closeWindow')());
    }),

    Chain.op((dialogApi) => {
      currentApi.set(dialogApi);
    })
  ]);

  const sTestClose = GeneralSteps.sequence([
    Mouse.sClickOn(Body.body(), '[aria-label="Close"]'),
    UiFinder.sNotExists(Body.body(), '[role="dialog"]')
  ]);

  Pipeline.async({}, [
    sTestOpen,
    Assertions.sAssertStructure('"tox-dialog__scroll-disable" should exist on the body',
      ApproxStructure.build((s, str, arr) => {
        return s.element('body', {
          classes: [ arr.has('tox-dialog__disable-scroll') ]
        });
      }),
      Body.body()
    ),
    Waiter.sTryUntil(
      'Waiting for an initial message to be received from the iframe',
      store.sAssertEq('Checking stuff', [ 'onMessage' ]),
      100,
      3000
    ),
    Step.label('Sending message to iframe', Step.sync(() => {
      // Send a message to the iframe
      currentApi.get().sendMessage({ message: 'Some message' });
    })),
    Waiter.sTryUntil(
      'Waiting for the reply message to be received from the iframe',
      store.sAssertEq('Checking stuff', [ 'onMessage', 'onMessage' ]),
      100,
      3000
    ),
    Mouse.sClickOn(Body.body(), 'button:contains("Barny Text")'),
    sTestClose,
    Waiter.sTryUntil(
      'Waiting for all dialog events when closing',
      store.sAssertEq('Checking stuff', [
        'onMessage',
        'onMessage',
        'onAction',
        'closeWindow',
        'onClose'
      ]),
      100,
      3000
    ),
    Assertions.sAssertStructure('"tox-dialog__scroll-disable" should have been removed from the body',
      ApproxStructure.build((s, str, arr) => {
        return s.element('body', {
          classes: [ arr.not('tox-dialog__disable-scroll') ]
        });
      }),
      Body.body()
    ),
  ], () => {
    helpers.destroy();
    success();
  }, failure);
});
开发者ID:tinymce,项目名称:tinymce,代码行数:91,代码来源:SilverUrlDialogTest.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript agar.Assertions类代码示例发布时间:2022-05-28
下一篇:
TypeScript styled.default函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap