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


TypeScript alloy.TestHelpers类代码示例

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


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

示例1: function

export default function () {
  const store = TestHelpers.TestStore();

  const editorState = {
    start: Cell(null),
    content: Cell('')
  };

  const sPrepareState = function (node, content) {
    return Step.sync(function () {
      editorState.start.set(node);
      editorState.content.set(content);
    });
  };

  const editor = {
    selection: {
      getStart: editorState.start.get,
      getContent: editorState.content.get,
      select: Fun.noop
    },

    insertContent (data) {
      store.adder({ method: 'insertContent', data })();
    },
    execCommand (name, ui, args) {
      store.adder({ method: 'execCommand', data: Objects.wrap(name, args) })();
    },
    dom: {
      createHTML (tag, attributes, innerText) {
        return { tag, attributes, innerText };
      },
      encode: Fun.identity
    },
    focus: Fun.noop,
    ui: {
      registry: {
        getAll: () => {
          return {
            icons: {}
          };
        }
      }
    }
  };

  return {
    editor: Fun.constant(editor),
    adder: store.adder,
    assertEq: store.assertEq,
    sAssertEq: store.sAssertEq,
    sClear: store.sClear,
    sPrepareState
  };
}
开发者ID:tinymce,项目名称:tinymce,代码行数:55,代码来源:TestEditor.ts

示例2: TinyApis

UnitTest.asynctest('Editor ContextToolbar test', (success, failure) => {
  const store = TestHelpers.TestStore();

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

      Pipeline.async({ }, [
        Log.stepsAsStep('TBA', 'Moving selection away from the context toolbar predicate should make it disappear', [
          tinyApis.sFocus,
          tinyApis.sSetContent('<p>One <a href="http://tiny.cloud">link</a> Two</p>'),
          tinyApis.sSetCursor([ 0, 1, 0 ], 'L'.length),
          UiFinder.sWaitForVisible('Waiting for toolbar', Body.body(), '.tox-pop'),
          // NOTE: This internally fires a nodeChange
          tinyApis.sSetCursor([ 0, 0 ], 'O'.length),
          Waiter.sTryUntil(
            'Waint for dialog to disappear after nodeChange',
            UiFinder.sNotExists(Body.body(), '.tox-pop'),
            100,
            1000
          )
        ])
      ], onSuccess, onFailure);
    },
    {
      theme: 'silver',
      base_url: '/project/tinymce/js/tinymce',
      setup: (ed: Editor) => {
        ed.ui.registry.addButton('alpha', {
          text: 'Alpha',
          onAction: store.adder('alpha-exec')
        });
        ed.ui.registry.addContextToolbar('test-toolbar', {
          predicate: (node) => node.nodeName && node.nodeName.toLowerCase() === 'a',
          items: 'alpha'
        });
      }
    },
    () => {
      success();
    },
    failure
  );
});
开发者ID:tinymce,项目名称:tinymce,代码行数:44,代码来源:ContextToolbarTest.ts

示例3: TestExtras

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

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

  const store = TestHelpers.TestStore();

  const dialogA: Types.Dialog.DialogApi<any> = {
    title: 'DialogA',
    body: {
      type: 'panel',
      items: [
      ]
    },
    buttons: [
      {
        type: 'custom',
        name: 'Dest.DialogB',
        text: 'Destination: DialogB'
      },
      {
        type: 'custom',
        name: 'disable-dest',
        text: 'Disable other'
      },
      {
        type: 'custom',
        name: 'enable-dest',
        text: 'Enable other'
      }
    ],
    initialData: {

    },
    onSubmit: (api) => {
      store.adder('onSubmitA');
      api.close();
    },
    onClose: store.adder('onCloseA'),
    onChange: store.adder('onChangeA'),
    onAction: (dialogApi, actionData) => {
      if (actionData.name === 'Dest.DialogB') {
        dialogApi.redial(dialogB);
      } else if (actionData.name === 'disable-dest') {
        dialogApi.disable('Dest.DialogB');
      } else if (actionData.name === 'enable-dest') {
        dialogApi.enable('Dest.DialogB');
      }
    }
  };

  const dialogB: Types.Dialog.DialogApi<any> =  {
    title: 'DialogB',
    body: {
      type: 'panel',
      items: [ ]
    },
    buttons: [
      {
        type: 'custom',
        name: 'Dest.DialogC',
        text: 'Destination: DialogC'
      },
    ],
    initialData: { },
    onSubmit: (api) => {
      store.adder('onSubmitB');
      api.close();
    },
    onClose: store.adder('onCloseB'),
    onAction: (dialogApi, actionData) => {
      if (actionData.name === 'Dest.DialogC') {
        dialogApi.redial(dialogC);
      }
    }
  };

  const dialogC: Types.Dialog.DialogApi<any> =  {
    title: 'DialogC',
    body: {
      type: 'tabpanel',
      tabs: [
        {
          title: 'one',
          items: [
            {
              type: 'input',
              name: 'c.alpha'
            }
          ]
        },
        {
          title: 'two',
          items: [

          ]
        }
      ]
    },
//.........这里部分代码省略.........
开发者ID:tinymce,项目名称:tinymce,代码行数:101,代码来源:WindowManagerRedialTest.ts

示例4: structWithTitleAndIconAndText

UnitTest.asynctest('Editor Autocompleter test', (success, failure) => {
  const store = TestHelpers.TestStore();

  interface AutocompleterListStructure {
    type: 'list';
    hasIcons: boolean;
    groups: { title: string; text: string; icon?: string }[][];
  }

  interface AutocompleterGridStructure {
    type: 'grid';
    groups: { title: string; icon?: string }[][];
  }

  type AutocompleterStructure = AutocompleterListStructure | AutocompleterGridStructure;

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

      const eDoc = Element.fromDom(editor.getDoc());

      const structWithTitleAndIconAndText = (d) => (s, str, arr) => {
        return s.element('div', {
          classes: [ arr.has('tox-collection__item') ],
          attrs: {
            title: str.is(d.title)
          },
          children: [
            s.element('div', {
              classes: [ arr.has('tox-collection__item-icon') ],
              children: [
                s.text(str.is(d.icon))
              ]
            }),
            s.element('div', {
              classes: [ arr.has('tox-collection__item-label') ],
              html: str.is(d.text)
            })
          ]
        });
      };

      const structWithTitleAndText = (d) => (s, str, arr) => {
        return s.element('div', {
          classes: [ arr.has('tox-collection__item') ],
          attrs: {
            title: str.is(d.title)
          },
          children: [
            s.element('div', {
              classes: [ arr.has('tox-collection__item-label') ],
              html: str.is(d.text)
            })
          ]
        });
      };

      const structWithTitleAndIcon = (d) => (s, str, arr) => {
        return s.element('div', {
          classes: [ arr.has('tox-collection__item') ],
          attrs: {
            title: str.is(d.title)
          },
          children: [
            s.element('div', {
              classes: [ arr.has('tox-collection__item-icon') ],
              children: [
                s.text(str.is(d.icon))
              ]
            })
          ]
        });
      };

      const sWaitForAutocompleteToClose = Waiter.sTryUntil(
        'Autocompleter should disappear',
        UiFinder.sNotExists(Body.body(), '.tox-autocompleter'),
        100,
        1000
      );

      const sAssertAutocompleterStructure = (structure: AutocompleterStructure) => {
        return Chain.asStep(Body.body(), [
          UiFinder.cFindIn('.tox-autocompleter'),
          Assertions.cAssertStructure(
            'Checking the autocompleter',
            ApproxStructure.build((s, str, arr) => {
              return s.element('div', {
                classes: [ arr.has('tox-autocompleter') ],
                children: [
                  s.element('div', {
                    classes: [ arr.has('tox-menu'), arr.has(`tox-collection--${structure.type}`), arr.has('tox-collection') ],
                    children: Arr.map(structure.groups, (group) => {
                      return s.element('div', {
                        classes: [ arr.has('tox-collection__group') ],
                        children: Arr.map(group, (d) => {
                          if (structure.type === 'list') {
                            if (structure.hasIcons) {
//.........这里部分代码省略.........
开发者ID:tinymce,项目名称:tinymce,代码行数:101,代码来源:AutocompleterTest.ts

示例5: TestExtras

UnitTest.asynctest('WindowManager:simple-dialog access 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 = (params) => Chain.asStep({ }, [
    Chain.mapper((_) => {
      return windowManager.open({
        title: 'Silver Test Access Dialog',
        body: {
          type: 'panel',
          items: [
            {
              type: 'input',
              name: 'fieldA',
              label: 'Label'
            },
          ]
        },
        buttons: [
          {
            type: 'custom',
            name: 'async.setData',
            text: 'Call api.setData after two seconds',
            align: 'start',
            primary: true
          },
        ],
        initialData: {
          fieldA: 'Init Value'
        },
        onSubmit: store.adder('onSubmit'),
        onClose: store.adder('onClose'),
        onCancel: store.adder('onCancel'),
        onChange: store.adder('onChange'),
        onAction: (api, _actionData) => {
          Delay.setTimeout(() => {
            const currentData = api.getData();
            store.adder('currentData: ' + currentData.fieldA)();
            // Currently, this will be ignored once the dialog is closed.
            api.setData({
              fieldA: 'New Value'
            });

            // Check all APIs do not throw errors
            api.disable('async.setData');
            api.enable('async.setData');
            api.block('message');
            api.unblock();
            api.showTab('new tab');
            // Currently, it is only going to validate it if the dialog is still open
            api.redial({
              title: 'temporary redial to check the API',
              body: {
                type: 'panel',
                items: []
              },
              buttons: []
            });
            api.close();

            store.adder('newData: ' + currentData.fieldA)();
          }, 2000);
        }
      }, params, () => store.adder('closeWindow')());
    }),

    Chain.op((dialogApi) => {
      Assertions.assertEq('Initial data', {
        fieldA: 'Init Value'
      }, dialogApi.getData());

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

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

  const testDialog = (label: string, params: { inline?: string }) => Logger.t(
    `Testing ${label}`,
    GeneralSteps.sequence([
      store.sClear,
      Logger.t(
        'Open a dialog, with a change button that accesses API asynchronously',
        sTestOpen(params)
      ),

      Logger.t(
        'Trigger the async functions by clicking on the button',
        Mouse.sClickOn(Body.body(), 'button:contains("Call")')
      ),

      Logger.t(
        'Click on the close button, so that dialog is shut down',
//.........这里部分代码省略.........
开发者ID:tinymce,项目名称:tinymce,代码行数:101,代码来源:SilverDialogApiAccessTest.ts

示例6: Theme

UnitTest.asynctest('OxideGridCollectionMenuTest', (success, failure) => {
  Theme();

  const store = TestHelpers.TestStore();

  TinyLoader.setup(
    (editor, onSuccess, onFailure) => {
      const doc = Element.fromDom(document);

      Pipeline.async({ }, Logger.ts(
        'Check structure of grid collection menu',
        [
          TestHelpers.GuiSetup.mAddStyles(doc, [
            ':focus { background-color: rgb(222, 224, 226); }'
          ]),
          Mouse.sClickOn(Body.body(), '.tox-split-button__chevron'),
          UiFinder.sWaitForVisible('Waiting for menu', Body.body(), '[role="menu"]'),
          Chain.asStep(Body.body(), [
            UiFinder.cFindIn('[role="menu"]'),
            Assertions.cAssertStructure(
              'Checking structure',
              ApproxStructure.build((s, str, arr) => {
                return s.element('div', {
                  classes: [ arr.has('tox-menu'), arr.has('tox-collection'), arr.has('tox-collection--grid') ],
                  children: [
                    s.element('div', {
                      classes: [ arr.has('tox-collection__group') ],
                      children: Arr.map([ '1', '2', '3', '4', '5', '6', '7', '8' ], (num) => {
                        return s.element('div', {
                          classes: [ arr.has('tox-collection__item') ],
                          attrs: {
                            title: str.is(num)
                          },
                          children: [
                            // NOTE: The oxide demo page has div, but I think that's just a mistake
                            s.element('div', {
                             classes: [ arr.has('tox-collection__item-icon') ],
                             children: [
                               s.element('svg', {})
                             ]
                            })
                          ]
                        });
                      })
                    })
                  ]
                });
              })
            )
          ]),

          // Without layout, the flatgrid cannot be calculated on phantom
          navigator.userAgent.indexOf('PhantomJS') > -1 ? Step.pass : GeneralSteps.sequence([
            FocusTools.sTryOnSelector('Focus should be on 1', doc, '.tox-collection__item[title="1"]'),
            Keyboard.sKeydown(doc, Keys.right(), { }),
            FocusTools.sTryOnSelector('Focus should be on 2', doc, '.tox-collection__item[title="2"]'),
            Keyboard.sKeydown(doc, Keys.right(), { }),
            FocusTools.sTryOnSelector('Focus should be on 3', doc, '.tox-collection__item[title="3"]')
          ]),
          TestHelpers.GuiSetup.mRemoveStyles
        ]
      ), onSuccess, onFailure);
    },
    {
      theme: 'silver',
      menubar: true,
      toolbar: 'grid-button',
      base_url: '/project/tinymce/js/tinymce',
      setup: (ed: Editor) => {
        ed.ui.registry.addSplitButton('grid-button', {
          type: 'splitbutton',
          columns: 'auto',
          fetch: (callback) => {
            callback(
              Arr.map([ '1', '2', '3', '4', '5', '6', '7', '8' ], (num) => {
                return {
                  type: 'choiceitem',
                  value: num,
                  text: num,
                  icon: 'fake-icon-name'
                } as Menu.ChoiceMenuItemApi;
              })
            );
          },
          onAction: store.adder('onAction'),
          onItemAction: store.adder('onItemAction')
        });
      }
    },
    () => {
      success();
    },
    failure
  );
});
开发者ID:tinymce,项目名称:tinymce,代码行数:95,代码来源:OxideGridCollectionMenuTest.ts

示例7: function

UnitTest.asynctest('tinymce.themes.silver.test.browser.sidebar.SidebarTest', function (success, failure) {
  const store = TestHelpers.TestStore();
  Theme();

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

    const sClickAndAssertEvents = function (tooltip, expected: EventLog[]) {
      return GeneralSteps.sequence([
        store.sClear,
        tinyUi.sClickOnToolbar('Toggle sidebar', 'button[aria-label="' + tooltip + '"]'),
        Waiter.sTryUntil('Checking sidebar callbacks', store.sAssertEq('Asserting sidebar callbacks', expected), 10, 1000),
      ]);
    };

    Pipeline.async(editor, Log.steps('TBA', 'Sidebar actions test', [
      Chain.asStep(Body.body(), [
        UiFinder.cFindIn('.tox-sidebar-wrap .tox-sidebar'),
        Assertions.cAssertStructure('Checking structure', ApproxStructure.build((s, str, arr) => {
          return s.element('div', {
            classes: [arr.has('tox-sidebar')],
            children: [
              s.element('div', {
                classes: [arr.has('tox-sidebar__slider')],
                children: [
                  s.element('div', {
                    classes: [arr.has('tox-sidebar__pane-container')],
                    children: [
                      s.element('div', {
                        classes: [arr.has('tox-sidebar__pane')],
                        styles: { display: str.is('none') },
                        attrs: { 'aria-hidden': str.is('true') }
                      }),
                      s.element('div', {
                        classes: [arr.has('tox-sidebar__pane')],
                        styles: { display: str.is('none') },
                        attrs: { 'aria-hidden': str.is('true') }
                      }),
                      s.element('div', {
                        classes: [arr.has('tox-sidebar__pane')],
                        styles: { display: str.is('none') },
                        attrs: { 'aria-hidden': str.is('true') }
                      })
                    ]
                  })
                ]
              })
            ]
          });
        }))
      ]),
      Waiter.sTryUntil('Checking initial events', store.sAssertEq('Asserting intial render and hide of sidebar', [
        {name: 'mysidebar1:render', index: 0},
        {name: 'mysidebar2:render', index: 1},
        {name: 'mysidebar3:render', index: 2},
        {name: 'mysidebar1:hide', index: 0},
        {name: 'mysidebar2:hide', index: 1},
        {name: 'mysidebar3:hide', index: 2},
      ]), 10, 1000),
      sClickAndAssertEvents('My sidebar 1', [{name: 'mysidebar1:show', index: 0}]),
      sClickAndAssertEvents('My sidebar 2', [{name: 'mysidebar1:hide', index: 0}, {name: 'mysidebar2:show', index: 1}]),
      sClickAndAssertEvents('My sidebar 3', [{name: 'mysidebar2:hide', index: 1}, {name: 'mysidebar3:show', index: 2}]),
      sClickAndAssertEvents('My sidebar 3', [{name: 'mysidebar3:hide', index: 2}]),
    ]), onSuccess, onFailure);
  }, {
    theme: 'silver',
    base_url: '/project/tinymce/js/tinymce',
    toolbar: 'mysidebar1 mysidebar2 mysidebar3',
    setup (editor) {
      const logEvent = (name: string) => (api: Sidebar.SidebarInstanceApi) => {
        const index = Traverse.findIndex(Element.fromDom(api.element())).getOr(-1);
        const entry: EventLog = {name, index};
        store.adder(entry)();
      };
      const handleSetup = (eventName: string) => (api: Sidebar.SidebarInstanceApi) => {
        api.element().appendChild(Element.fromHtml('<div style="width: 200px; background: red;"></div>').dom());
        logEvent(eventName)(api);
        return () => {};
      };
      editor.ui.registry.addSidebar('mysidebar1', {
        tooltip: 'My sidebar 1',
        icon: 'bold',
        onSetup: handleSetup('mysidebar1:render'),
        onShow: logEvent('mysidebar1:show'),
        onHide: logEvent('mysidebar1:hide')
      });

      editor.ui.registry.addSidebar('mysidebar2', {
        tooltip: 'My sidebar 2',
        icon: 'italic',
        onSetup: handleSetup('mysidebar2:render'),
        onShow: logEvent('mysidebar2:show'),
        onHide: logEvent('mysidebar2:hide')
      });

      editor.ui.registry.addSidebar('mysidebar3', {
        tooltip: 'My sidebar 3',
        icon: 'comment',
        onSetup: handleSetup('mysidebar3:render'),
        onShow: logEvent('mysidebar3:show'),
//.........这里部分代码省略.........
开发者ID:tinymce,项目名称:tinymce,代码行数:101,代码来源:SidebarTest.ts

示例8: function

UnitTest.test('Test: phantom.bridge.LinkBridgeTest', function () {
  const store = TestHelpers.TestStore();

  const editorState = {
    start: Cell(null),
    content: Cell('')
  };

  const editor = {
    selection: {
      getStart: editorState.start.get,
      getContent: editorState.content.get,
      select: Fun.noop
    },
    insertContent (data) {
      store.adder({ method: 'insertContent', data })();
    },
    execCommand (name) {
      store.adder({ method: 'execCommand', data: name })();
    },
    dom: {
      createHTML (tag, attributes, innerText) {
        return { tag, attributes, innerText };
      },
      encode: Fun.identity
    },
    focus: Fun.noop
  };

  const checkGetNoLink = function (rawScenario) {
    const schema = ValueSchema.objOfOnly([
      FieldSchema.strict('label'),
      FieldSchema.defaulted('nodeText', ''),
      FieldSchema.defaulted('selection', ''),
      FieldSchema.strict('expected')
    ]);

    const scenario = ValueSchema.asRawOrDie(rawScenario.label, schema, rawScenario);

    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());
    });
  };

  const checkGetALink = function (rawScenario) {
    const schema = ValueSchema.objOfOnly([
      FieldSchema.strict('label'),
      FieldSchema.defaulted('linkHtml', ''),
      FieldSchema.defaulted('selection', ''),
      FieldSchema.strict('expected')
    ]);

    const scenario = ValueSchema.asRawOrDie(rawScenario.label, schema, rawScenario);

    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());
    });
  };

  const checkApply = function (rawScenario) {
    const toResult = (info, param) => Option.from(info[param]).fold(() => Result.error('Missing ' + param), Result.value);
    const scenario = {
      label: Option.from(rawScenario.label).getOrDie('Missing label'),
      info: Option.from(rawScenario.info).map((info) => ({
        url: toResult(info, 'url'),
        text: toResult(info, 'text'),
        title: toResult(info, 'title'),
        target: toResult(info, 'target'),
        link: toResult(info, 'link'),
      })).getOrDie('Missing info'),
      mutations: Option.from(rawScenario.mutations).getOr(Fun.noop),
      expected: Option.from(rawScenario.expected).getOr([]),
    };

    Logger.sync('setInfo ... ' + scenario.label, function () {
      store.clear();
      LinkBridge.applyInfo(editor, scenario.info);
      store.assertEq('Checking store', scenario.expected);
      const link = scenario.info.link.bind(Fun.identity);
      link.each(scenario.mutations);
    });
  };

  checkGetNoLink({
    label: 'Basic text node with no text',
    expected: ''
  });
//.........这里部分代码省略.........
开发者ID:tinymce,项目名称:tinymce,代码行数:101,代码来源:LinkBridgeTest.ts

示例9: 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

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