本文整理匯總了TypeScript中@ephox/agar.Guard.tryUntil方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Guard.tryUntil方法的具體用法?TypeScript Guard.tryUntil怎麽用?TypeScript Guard.tryUntil使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@ephox/agar.Guard
的用法示例。
在下文中一共展示了Guard.tryUntil方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: TinyUi
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyUi = TinyUi(editor);
Pipeline.async({}, [
Log.stepsAsStep('TBA', 'Image: image proportion constrains should work directly', [
tinyUi.sClickOnToolbar('click image button', 'button[aria-label="Insert/edit image"]'),
Chain.asStep({}, [
Chain.fromParent(tinyUi.cWaitForPopup('Wait for dialog', 'div[role="dialog"]'),
[
Chain.fromChains([
UiFinder.cFindIn('button.tox-browse-url'),
Mouse.cClick
]),
Chain.control(
cAssertInputValue(generalTabSelectors.width, '1'),
Guard.tryUntil('did not find width input with value 1', 10, 1000)
),
cSetInputValue(generalTabSelectors.height, '5'),
Chain.control(
cAssertInputValue(generalTabSelectors.width, '5'),
Guard.tryUntil('did not find width input with value 5', 10, 1000)
),
]
),
tinyUi.cSubmitDialog(),
Chain.inject(editor),
cAssertCleanHtml('Checking output', '<p><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="" width="5" height="5" /></p>')
])
])
], onSuccess, onFailure);
}, {
示例2:
const cWaitForContextmenuState = (state: boolean) => Chain.control(
Chain.op(() => {
const contextToolbar = UiFinder.findIn(Body.body(), '.tox-pop');
Assertions.assertEq('no context toolbar', state, contextToolbar.isValue());
}),
Guard.tryUntil('Wait for context menu to appear.', 100, 3000)
);
示例3: function
Obj.each(data, function (data, label) {
chains.push(
cFireFakePasteEvent(data),
Chain.control(
cAssertEditorContent(label, expected),
Guard.tryUntil('Wait for paste to succeed.', 100, 1000)
),
cClearEditor()
);
});
示例4:
const cFindInDialog = (selector) => Chain.control(
Chain.fromChains([
Chain.inject(TinyDom.fromDom(document.body)),
Chain.control(
UiFinder.cFindIn('[role="dialog"]'),
Guard.tryUntil('Waiting for dialog', 100, 1000)
),
UiFinder.cFindIn(selector)
]),
Guard.addLogging('Find in dialog')
);
示例5: function
const assertStructureInDialog = function (errString, objStruc, waitOn, clickOn) {
return Logger.t('Assert structure in dialog', Chain.asStep(TinyDom.fromDom(document.body), [
UiFinder.cWaitFor('Could not find notification', waitOn),
Mouse.cClickOn(clickOn),
Chain.control(
Chain.op((panel) => {
Assertions.assertPresence(errString, objStruc, panel);
}),
Guard.tryUntil('Keep waiting', 100, 4000)
)
]));
};
示例6: function
const cAssertEmbedValue = function (expected) {
return Chain.control(
Chain.fromChains([
UiFinder.cFindIn('label:contains("Paste your embed code below:")'),
Chain.mapper(function (elm) {
return TinyDom.fromDom(document.getElementById(elm.dom().htmlFor));
}),
UiControls.cGetValue,
Assertions.cAssertHtml('has expected html', expected)
]),
Guard.tryUntil('did not get correct html', 10, 3000)
);
};
示例7:
const sAssertButtonToggledState = (name: string, state: boolean) => {
return Chain.asStep(Body.body(), [
Chain.control(
Chain.fromChains( [
UiFinder.cFindIn(`.tox-toolbar button[aria-label="${name}"]`),
Assertions.cAssertStructure(`Check ${name} button is ${state ? 'active' : 'inactive'}`,
ApproxStructure.build((s, str, arr) => {
return s.element('button', {
classes: [ state ? arr.has('tox-tbtn--enabled') : arr.not('tox-tbtn--enabled') ]
});
})
)
]),
Guard.tryUntil('wait for toolbar button state', 100, 1000)
)
]);
};
示例8: function
const cDragHandle = function (id, deltaH, deltaV) {
return NamedChain.asChain([
NamedChain.direct(NamedChain.inputName(), Chain.identity, 'editor'),
NamedChain.direct('editor', cGetBody, 'editorBody'),
NamedChain.read('editorBody', Chain.control(
UiFinder.cFindIn('#mceResizeHandle' + id),
Guard.tryUntil('wait for resize handlers', 100, 40000)
)),
NamedChain.read('editorBody', Chain.fromChains([
UiFinder.cFindIn('#mceResizeHandle' + id),
Mouse.cMouseDown,
Mouse.cMouseMoveTo(deltaH, deltaV),
Mouse.cMouseUp
])),
NamedChain.outputInput
]);
};
示例9: TinyUi
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyUi = TinyUi(editor);
Pipeline.async({}, [
Logger.t('image proportion constrains should work directly', GeneralSteps.sequence([
tinyUi.sClickOnToolbar('click image button', 'div[aria-label="Insert/edit image"] button'),
Chain.asStep({}, [
Chain.fromParent(tinyUi.cWaitForPopup('Wait for dialog', 'div[role="dialog"]'),
[
Chain.fromChains([
UiFinder.cFindIn('i.mce-i-browse'),
Mouse.cClick
]),
Chain.fromChains([
Chain.control(
Chain.fromChains([
UiFinder.cFindIn('input[aria-label="Width"]'),
UiControls.cGetValue,
Assertions.cAssertEq('should be 1', '1')
]),
Guard.tryUntil('did not find input with value 1', 10, 3000)
)
]),
Chain.fromChains([
UiFinder.cFindIn('input[aria-label="Height"]'),
UiControls.cSetValue('5'),
cFakeEvent('change')
]),
Chain.fromChains([
UiFinder.cFindIn('input[aria-label="Width"]'),
UiControls.cGetValue,
Assertions.cAssertEq('should have changed to 5', '5')
]),
Chain.fromChains([
UiFinder.cFindIn('div.mce-primary button'),
Mouse.cClick
])
]
)
])
]))
], onSuccess, onFailure);
}, {
示例10: function
UnitTest.asynctest('browser.tinymce.plugins.image.FigureResizeTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
ModernTheme();
ImagePlugin();
const cGetBody = Chain.mapper(function (editor) {
return TinyDom.fromDom(editor.getBody());
});
const cGetElementSize = Chain.mapper(function (elm) {
const elmStyle = elm.dom().style;
return { w: elmStyle.width, h: elmStyle.height };
});
const cDragHandleRight = function (px) {
return Chain.op(function (input) {
const dom = input.editor.dom;
const target = input.resizeSE.dom();
const pos = dom.getPos(target);
dom.fire(target, 'mousedown', { screenX: pos.x, screenY: pos.y });
dom.fire(target, 'mousemove', { screenX: pos.x + px, screenY: pos.y });
dom.fire(target, 'mouseup');
});
};
Pipeline.async({}, [
Chain.asStep({}, [
Editor.cFromSettings({
plugins: 'image',
toolbar: 'image',
indent: false,
image_caption: true,
height: 400,
skin_url: '/project/js/tinymce/skins/lightgray'
}),
UiChains.cClickOnToolbar('click image button', 'div[aria-label="Insert/edit image"]'),
UiChains.cFillActiveDialog({
src: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
width: 100,
height: 100,
caption: true
}),
UiChains.cSubmitDialog(),
NamedChain.asChain([
NamedChain.direct(NamedChain.inputName(), Chain.identity, 'editor'),
NamedChain.direct('editor', cGetBody, 'editorBody'),
// click the image, but expect the handles on the figure
NamedChain.direct('editorBody', UiFinder.cFindIn('figure > img'), 'img'),
NamedChain.direct('img', Mouse.cTrueClick, '_'),
NamedChain.direct(NamedChain.inputName(), ApiChains.cAssertSelection([], 0, [], 1), '_'),
NamedChain.direct('editorBody', Chain.control(
UiFinder.cFindIn('#mceResizeHandlese'),
Guard.tryUntil('wait for resize handlers', 100, 40000)
), '_'),
// actually drag the handle to the right
NamedChain.direct('editorBody', UiFinder.cFindIn('#mceResizeHandlese'), 'resizeSE'),
NamedChain.write('_', cDragHandleRight(100)),
NamedChain.direct('img', cGetElementSize, 'imgSize'),
NamedChain.direct('imgSize', Assertions.cAssertEq('asserting image size after resize', { w: '200px', h: '200px' }), '_'),
NamedChain.output('editor')
]),
Editor.cRemove
])
], function () {
success();
}, failure);
});