-
Notifications
You must be signed in to change notification settings - Fork 795
/
Copy pathkarma.spec.ts
31 lines (23 loc) · 1.15 KB
/
karma.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { setupDomTests } from '../util';
describe('custom-elements-delegates-focus', () => {
const { setupDom, tearDownDom } = setupDomTests(document);
let app: HTMLElement;
beforeEach(async () => {
app = await setupDom('/custom-elements-delegates-focus/index.html');
});
afterEach(tearDownDom);
it('sets delegatesFocus correctly', async () => {
expect(customElements.get('custom-elements-delegates-focus')).toBeDefined();
const elm: Element = app.querySelector('custom-elements-delegates-focus');
expect(elm.shadowRoot).toBeDefined();
// as of TypeScript 4.3, `delegatesFocus` does not exist on the `shadowRoot` object
expect((elm.shadowRoot as any).delegatesFocus).toBe(true);
});
it('does not set delegatesFocus when shadow is set to "true"', async () => {
expect(customElements.get('custom-elements-no-delegates-focus')).toBeDefined();
const elm: Element = app.querySelector('custom-elements-no-delegates-focus');
expect(elm.shadowRoot).toBeDefined();
// as of TypeScript 4.3, `delegatesFocus` does not exist on the `shadowRoot` object
expect((elm.shadowRoot as any).delegatesFocus).toBe(false);
});
});