当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Harness.sendEvent方法代码示例

本文整理汇总了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();
开发者ID:dylans,项目名称:widgets,代码行数:31,代码来源:TabButton.ts

示例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
			});
开发者ID:bitpshr,项目名称:widgets,代码行数:31,代码来源:Checkbox.ts

示例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');
		},
开发者ID:bitpshr,项目名称:widgets,代码行数:31,代码来源:CalendarCell.ts

示例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));
		}
	}
});
开发者ID:bitpshr,项目名称:widgets,代码行数:30,代码来源:ListboxOption.ts

示例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
			});
开发者ID:dylans,项目名称:widgets,代码行数:29,代码来源:ComboBox.ts

示例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', {
开发者ID:dylans,项目名称:widgets,代码行数:31,代码来源:Toolbar.ts


注:本文中的@dojo/test-extras/harness.Harness.sendEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。