本文整理汇总了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', {