當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript UnitTest.test方法代碼示例

本文整理匯總了TypeScript中@ephox/agar.UnitTest.test方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript UnitTest.test方法的具體用法?TypeScript UnitTest.test怎麽用?TypeScript UnitTest.test使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@ephox/agar.UnitTest的用法示例。


在下文中一共展示了UnitTest.test方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: method

UnitTest.test('DialogChanges', () => {
  Logger.sync(
    'Quick Toolbars plugin: Quick Toolbars Editor Settings and default values',
    () => {

      const test = (label: string, method: (editor: Editor) => string, settings: any, expected: string) => {
        const mockEditor = {
          getParam: (name, defaultValue) => Obj.get(settings, name).getOr(defaultValue),
          settings
        } as any;

        Logger.sync(label, () => {
          const result = method(mockEditor);
          RawAssertions.assertEq(label, expected, result);
        });
      };

      test('getTextSelectionToolbarItems: testing for empty string should return empty string',
        Settings.getTextSelectionToolbarItems,
        {
          quickbars_selection_toolbar: ''
        },
        ''
      );

      test('getTextSelectionToolbarItems: testing for boolean false should return empty string',
        Settings.getTextSelectionToolbarItems,
        {
          quickbars_selection_toolbar: false
        },
        ''
      );

      test('getTextSelectionToolbarItems: testing for boolean true should fallback to defaults',
        Settings.getTextSelectionToolbarItems,
        {
          quickbars_selection_toolbar: true
        },
        'bold italic | quicklink h2 h3 blockquote'
      );

      test('getTextSelectionToolbarItems: testing for undefined should fallback to defaults',
        Settings.getTextSelectionToolbarItems,
        {
          // intentionally blank undefined
        },
        'bold italic | quicklink h2 h3 blockquote'
      );

      test('getTextSelectionToolbarItems: testing for custom config string',
        Settings.getTextSelectionToolbarItems,
        {
          quickbars_selection_toolbar: 'hello | friend'
        },
        'hello | friend'
      );

      test('getInsertToolbarItems: testing for empty string should return empty string',
        Settings.getInsertToolbarItems,
        {
          quickbars_insert_toolbar: ''
        },
        ''
      );

      test('getInsertToolbarItems: testing for boolean false should return empty string',
        Settings.getInsertToolbarItems,
        {
          quickbars_insert_toolbar: false
        },
        ''
      );

      test('getInsertToolbarItems: testing for boolean true should fallback to defaults',
        Settings.getInsertToolbarItems,
        {
          quickbars_insert_toolbar: true
        },
        'quickimage quicktable'
      );

      test('getInsertToolbarItems: testing for undefined should fallback to defaults',
        Settings.getInsertToolbarItems,
        {
          // intentionally blank undefined
        },
        'quickimage quicktable'
      );

      test('getInsertToolbarItems: testing for custom config string',
        Settings.getInsertToolbarItems,
        {
          quickbars_insert_toolbar: 'bye | now'
        },
        'bye | now'
      );

    }
  );
});
開發者ID:tinymce,項目名稱:tinymce,代碼行數:100,代碼來源:EditorSettingsTest.ts

示例2: Error

UnitTest.test('DialogChanges', () => {

  Logger.sync(
    'Basic test',
    () => {
      // TODO TINY-2236 re-enable this (support will need to be added to bridge)
      const anchorList: ListItem[] = [
        { value: 'alpha', text: 'Alpha' },
        /* {
          text: 'GroupB',
          items: [
            { value: 'gamma', text: 'Gamma' }
          ]
        } */
      ];

      const assertNone = (label: string, previousText: string, catalog: ListItem[], data: Partial<LinkDialogData>) => {
        Logger.sync('assertNone(' + label + ')', () => {
          const actual = DialogChanges.getDelta(previousText, 'anchor', catalog, data);
          actual.each(
            (a) => { throw new Error('Should not have found replacement text'); }
          );
        });
      };

      const assertSome = (label: string, expected: DialogDelta, previousText: string, catalog: ListItem[], data: Partial<LinkDialogData>) => {
        Logger.sync('assertSome(' + label + ')', () => {
          const actual = DialogChanges.getDelta(previousText, 'anchor', catalog, data);
          RawAssertions.assertEq('Checking replacement text', expected, actual.getOrDie(
            'Should be some'
          ));
        });
      };

      assertSome('Current text empty + Has mapping', {
        url: {
          value: 'alpha',
          meta: {
            attach: Fun.noop,
            text: 'Alpha'
          }
        },
        text: 'Alpha'
      }, '', anchorList, {
        anchor: 'alpha',
        text: ''
      });

      assertNone('Current text empty + Has no mapping', '', anchorList, {
        anchor: 'beta',
        text: ''
      });

      // TODO TINY-2236 re-enable this (support will need to be added to bridge)
      /* assertSome('Current text empty + Has mapping in nested list', {
        url: {
          value: 'gamma',
          meta: {
            attach: Fun.noop,
            text: 'Gamma'
          }
        },
        text: 'Gamma'
      }, '', anchorList, {
        anchor: 'gamma',
        text: ''
      }); */

    }
  );
});
開發者ID:tinymce,項目名稱:tinymce,代碼行數:71,代碼來源:DialogChangesTest.ts


注:本文中的@ephox/agar.UnitTest.test方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。