本文整理匯總了TypeScript中@dojo/test-extras/harness.Harness.sendEvent方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Harness.sendEvent方法的具體用法?TypeScript Harness.sendEvent怎麽用?TypeScript Harness.sendEvent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@dojo/test-extras/harness.Harness
的用法示例。
在下文中一共展示了Harness.sendEvent方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: assignChildProperties
tabIndex: 0
});
assignChildProperties(expectedVdom, '0', {
tabIndex: 0
});
widget.expectRender(expectedVdom, 'Selected tab render with close button');
},
onCloseClick() {
const onCloseClick = sinon.stub();
widget.setProperties(props({
closeable: true,
onCloseClick
}));
widget.sendEvent('click', { selector: 'button' });
assert.isTrue(onCloseClick.called, 'onCloseClick handler called when close button clicked');
},
onClick() {
const onClick = sinon.stub();
widget.setProperties(props({ onClick }));
widget.sendEvent('click');
assert.isTrue(onClick.calledOnce, 'onClick handler called when tab is clicked');
assert.isTrue(onClick.calledWith(0), 'onClick called with index as argument');
widget.setProperties(props({
disabled: true,
onClick
}));
widget.getRender();
示例2: assignProperties
'aria-invalid': 'true',
readOnly: true,
'aria-readonly': 'true',
required: true
});
assignProperties(expectedVdom, {
extraClasses: { root: `${css.root} ${css.disabled} ${css.invalid} ${css.readonly} ${css.required}` }
});
widget.expectRender(expectedVdom);
},
'focused class'() {
let expectedVdom = expected(widget);
widget.expectRender(expectedVdom);
widget.sendEvent('focus', { selector: 'input' });
expectedVdom = expected(widget);
assignProperties(expectedVdom, {
classes: [ css.root, null, null, null, css.focused, null, null, null, null ]
});
widget.expectRender(expectedVdom, 'Should have focused class after focus event');
widget.sendEvent('blur', { selector: 'input' });
expectedVdom = expected(widget);
widget.expectRender(expectedVdom, 'Should not have focused class after blur event');
},
'toggle mode'() {
widget.setProperties({
mode: Mode.toggle
});
示例3: v
}, [
v('span', {}, [ '2' ])
]));
},
'Click handler called with correct arguments'() {
let clickedDate = 0, clickedDisabled = false;
widget.setProperties({
date: 1,
disabled: true,
onClick: (date: number, disabled: boolean) => {
clickedDate = date;
clickedDisabled = disabled;
}
});
widget.sendEvent('click');
assert.strictEqual(clickedDate, 1);
assert.isTrue(clickedDisabled);
widget.setProperties({
date: 2,
onClick: (date: number, disabled: boolean) => {
clickedDate = date;
clickedDisabled = disabled;
}
});
widget.getRender();
widget.sendEvent('click');
assert.strictEqual(clickedDate, 2);
assert.isFalse(clickedDisabled, 'disabled defaults to false');
},
示例4:
index: 1,
option: 'baz',
selected: true
});
widget.expectRender(v('div', {
'aria-disabled': 'true',
'aria-selected': null,
classes: [ css.option ],
id: 'bar',
role: 'option',
onclick: widget.listener
}, [ 'foo' ]));
},
'option click'() {
const onClick = sinon.stub();
widget.setProperties({
label: 'foo',
id: 'bar',
index: 1,
option: 'baz',
onClick
});
widget.sendEvent('click');
assert.isTrue(onClick.calledWith('baz', 1));
}
}
});
示例5: getExpectedVdom
tests: {
'renders with default properties'() {
const expected = getExpectedVdom(widget);
widget.expectRender(expected);
},
'renders with custom properties'() {
widget.setProperties(testProperties);
const expected = getExpectedVdom(widget, true, false, true);
widget.expectRender(expected);
},
'dropdown renders correctly when open'() {
widget.setProperties(testProperties);
widget.sendEvent('click', { selector: `.${css.trigger}` });
let expected = getExpectedVdom(widget, true, false, true);
expected = getExpectedVdom(widget, true, true, true);
widget.expectRender(expected);
},
'arrow click opens menu'() {
const onRequestResults = sinon.stub();
const onMenuChange = sinon.stub();
widget.setProperties({
...testProperties,
onRequestResults,
onMenuChange
});
示例6: v
fixedCss.toolbarFixed
]
}, [
null,
slidePaneVDom,
buttonVDom
]),
v('div', {
classes: [
css.content,
fixedCss.contentFixed
]
}, [])
]));
toolbar.sendEvent('click', { selector: `.${css.menuButton}` });
toolbar.getRender();
toolbar.callListener('onRequestClose', { key: 'slide-pane-menu' });
toolbar.expectRender(v('div', {
classes: [
css.root,
fixedCss.rootFixed,
css.collapsed,
fixedCss.onTopFixed
],
key: 'root',
dir: null,
lang: null
}, [
v('div', {