-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy pathindex.spec.js
More file actions
52 lines (47 loc) · 2.24 KB
/
index.spec.js
File metadata and controls
52 lines (47 loc) · 2.24 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import Component from 'x/component';
import { createElement } from 'lwc';
import ExportAsDefault from 'x/exportAsDefault';
import ExportAsDefaultWithOtherExports, {
exportee as exporteeAsDefault,
} from 'x/exportAsDefaultWithOtherExports';
import ExportDefaultClassWithOtherExports, {
exportee as exporteeDefaultClass,
} from 'x/exportDefaultClassWithOtherExports';
import { extractDataIds } from '../../../helpers/utils.js';
describe('default export', () => {
it('should work when a module exports non-components as default', () => {
const elm = createElement('x-component', { is: Component });
document.body.appendChild(elm);
const nodes = extractDataIds(elm);
expect(nodes.undef.textContent).toEqual('undefined');
expect(nodes.nil.textContent).toEqual('null');
expect(nodes.zero.textContent).toEqual('0');
expect(nodes.string.textContent).toEqual('"bar"');
});
it('should work with `export default class` syntax and other exports', async () => {
expect(exporteeDefaultClass).toBe('foo');
const elm = createElement('x-export-default-class-with-other-exports', {
is: ExportDefaultClassWithOtherExports,
});
document.body.appendChild(elm);
await Promise.resolve();
expect(elm.shadowRoot.querySelector('h1').textContent).toBe('hello world');
});
// TODO [#4020]: support additional syntax for default export
xit('should work with `export { ... as default }` syntax', async () => {
const elm = createElement('x-export-as-default', { is: ExportAsDefault });
document.body.appendChild(elm);
await Promise.resolve();
expect(elm.shadowRoot.querySelector('h1').textContent).toBe('hello world');
});
// TODO [#4020]: support additional syntax for default export
xit('should work with `export { ... as default }` syntax and other exports', async () => {
expect(exporteeAsDefault).toBe('foo');
const elm = createElement('x-export-as-default-with-other-exports', {
is: ExportAsDefaultWithOtherExports,
});
document.body.appendChild(elm);
await Promise.resolve();
expect(elm.shadowRoot.querySelector('h1').textContent).toBe('hello world');
});
});