本文整理汇总了TypeScript中@ephox/agar.Logger.sync方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Logger.sync方法的具体用法?TypeScript Logger.sync怎么用?TypeScript Logger.sync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/agar.Logger
的用法示例。
在下文中一共展示了Logger.sync方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
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'
));
});
};
示例2: Error
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'); }
);
});
};
示例3: method
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);
});
};
示例4: function
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());
});
};
示例5: function
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);
});
};