本文整理汇总了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'
);
}
);
});
示例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: ''
}); */
}
);
});