本文整理汇总了TypeScript中@stencil/core/testing.TestWindow类的典型用法代码示例。如果您正苦于以下问题:TypeScript TestWindow类的具体用法?TypeScript TestWindow怎么用?TypeScript TestWindow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestWindow类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: beforeEach
beforeEach(async () => {
window = new TestWindow();
element = await window.load({
components: [MadnessEnjineer],
html: '<madness-enjineer></madness-enjineer>'
});
});
示例2: beforeEach
beforeEach(async () => {
testWindow = new TestWindow();
element = await testWindow.load({
components: [MyComponent],
html: '<my-component></my-component>'
});
});
示例3: it
it('should pass properties down to <input>', async () => {
const win = new TestWindow();
const el = await win.load({
components: [Toggle],
html: '<ion-toggle disabled checked value="coding" name="primary"></ion-toggle>'
}) as HTMLIonToggleElement;
expect(el.disabled).toBe(true);
expect(el.checked).toBe(true);
expect(el.value).toBe('coding');
expect(el.name).toBe('primary');
const input = getInput(el);
expect(input).toHaveProperties({
disabled: true,
checked: true,
value: 'coding',
name: 'primary'
});
el.disabled = false;
el.checked = false;
el.value = 'design';
el.name = 'secondary';
await win.flush();
expect(input.disabled).toBe(false);
expect(input.checked).toBe(false);
expect(input.value).toBe('design');
expect(input.name).toBe('secondary');
});
示例4: describe
describe('rendering', () => {
let element: HTMLMyComponentElement;
let testWindow: TestWindow;
beforeEach(async () => {
testWindow = new TestWindow();
element = await testWindow.load({
components: [MyComponent],
html: '<my-component></my-component>'
});
});
it('should work without parameters', () => {
expect(element.textContent.trim()).toEqual('Hello, World! I\'m');
});
it('should work with a first name', async () => {
element.first = 'Peter';
await testWindow.flush();
expect(element.textContent.trim()).toEqual('Hello, World! I\'m Peter');
});
it('should work with a last name', async () => {
element.last = 'Parker';
await testWindow.flush();
expect(element.textContent.trim()).toEqual('Hello, World! I\'m Parker');
});
it('should work with both a first and a last name', async () => {
element.first = 'Peter';
element.last = 'Parker';
await testWindow.flush();
expect(element.textContent.trim()).toEqual('Hello, World! I\'m Peter Parker');
});
});
示例5: it
it('should work with both a first and a last name', async () => {
element.first = 'Peter';
element.last = 'Parker';
await testWindow.flush();
expect(element.textContent.trim()).toEqual('Hello, World! I\'m Peter Parker');
});