本文整理汇总了TypeScript中@ephox/agar.Assertions类的典型用法代码示例。如果您正苦于以下问题:TypeScript Assertions类的具体用法?TypeScript Assertions怎么用?TypeScript Assertions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Assertions类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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,
//.........这里部分代码省略.........
示例2: function
const assertRange = function (expected, actual) {
Assertions.assertEq('startContainers should be equal', true, expected.startContainer === actual.startContainer);
Assertions.assertEq('startOffset should be equal', true, expected.startOffset === actual.startOffset);
Assertions.assertEq('endContainer should be equal', true, expected.endContainer === actual.endContainer);
Assertions.assertEq('endOffset should be equal', true, expected.endOffset === actual.endOffset);
};
示例3:
return Step.sync(() => {
const returnVal = TableDelete.backspaceDelete(editor, false);
Assertions.assertEq('Should return true since the operation should have done something', true, returnVal);
});
示例4: menu
(doc, body, gui, component, store) => {
const input = component.getSystem().getByDom(
SelectorFind.descendant(component.element(), 'input').getOrDie(
'Could not find input'
)
).getOrDie();
return [
TestHelpers.GuiSetup.mAddStyles(doc, [
'.tox-menu { background: white; }',
'.tox-collection__item--active { background: #cadbee }'
]),
Step.sync(() => {
Focusing.focus(input);
}),
Keyboard.sKeydown(doc, Keys.down(), { }),
Waiter.sTryUntil(
'Waiting for menu to appear',
UiFinder.sExists(
sink,
'.tox-menu .tox-collection__item'
),
100,
4000
),
Chain.asStep(sink, [
UiFinder.cFindIn('[role="menu"]'),
Assertions.cAssertStructure(
'Checking structure of menu (especially text)',
ApproxStructure.build((s, str, arr) => {
return s.element('div', {
classes: [ arr.has('tox-menu'), arr.has('tox-collection--list'), arr.has('tox-collection') ],
children: [
s.element('div', {
classes: [ arr.has('tox-collection__group') ],
children: [
s.element('div', {
classes: [ arr.has('tox-collection__item')],
children: [
s.element('div', { html: str.is('Header1') })
]
}),
s.element('div', {
classes: [ arr.has('tox-collection__item')],
children: [
s.element('div', { html: str.is('Header2') })
]
})
]
}),
s.element('div', {
classes: [ arr.has('tox-collection__group') ],
children: [
s.element('div', {
children: [
s.element('div', { html: str.is('<top>') })
]
})
]
})
]
});
})
)
]),
UiControls.sSetValue(input.element(), 'He'),
Step.sync(() => {
AlloyTriggers.emit(input, NativeEvents.input());
}),
Waiter.sTryUntil(
'Waiting for the menu to update',
Chain.asStep(sink, [
UiFinder.cFindAllIn('.tox-collection__item'),
Chain.op((menuItems) => {
if (menuItems.length > 2) {
throw Error('Menu hasn\'t been updated yet');
}
})
]),
100,
3000
),
Chain.asStep(sink, [
UiFinder.cFindIn('[role="menu"]'),
Assertions.cAssertStructure(
'Checking the menu shows items that match the input string',
ApproxStructure.build((s, str, arr) => {
return s.element('div', {
classes: [ arr.has('tox-menu'), arr.has('tox-collection--list'), arr.has('tox-collection') ],
children: [
s.element('div', {
classes: [ arr.has('tox-collection__group') ],
children: [
s.element('div', {
classes: [ arr.has('tox-collection__item')],
//.........这里部分代码省略.........
示例5:
Chain.op((menu) => {
const checkMarks = Selectors.all('.tox-collection__item-icon');
Assertions.assertEq('only one check mark is displayed for active toggled menu items', 1, checkMarks.length);
})
示例6: teardown
}).then(function (result) {
Assertions.assertEq('Should be an result that is zero length', 0, result.length);
teardown(done);
});
示例7:
return Step.sync(function () {
const returnVal = BlockRangeDelete.backspaceDelete(editor, false);
Assertions.assertEq('Should return true since the operation should have done something', true, returnVal);
});
示例8:
return Chain.op(function (data: any) {
Assertions.assertStructure('', structure, data.parent);
});
示例9:
Step.sync(function () {
const toolstrip = iframe.dom().contentWindow.document.querySelector('.tinymce-mobile-toolstrip');
Assertions.assertEq('Checking that the toolstrip is off screen when window moves', true, toolstrip.getBoundingClientRect().top < 0);
}),
示例10: function
const sAssertPresense = function (selector) {
return Assertions.sAssertPresence('Detect presense of the element', selector, TinyDom.fromDom(editor.getBody()));
};