-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtemba-field-manager.test.ts
61 lines (54 loc) · 1.98 KB
/
temba-field-manager.test.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { expect, fixture } from '@open-wc/testing';
import { FieldManager } from '../src/fields/FieldManager';
import { TextInput } from '../src/textinput/TextInput';
import {
assertScreenshot,
getAttributes,
getClip,
loadStore
} from './utils.test';
export const getEle = async (attrs: any = {}) => {
const fm = `<temba-field-manager
${getAttributes(attrs)}
></temba-field-manager>`;
const parentNode = document.createElement('div');
parentNode.setAttribute('style', 'width: 600px;');
return (await fixture(fm, { parentNode })) as FieldManager;
};
describe('temba-field-manager', () => {
it('renders default', async () => {
await loadStore();
const fm: FieldManager = await getEle();
await assertScreenshot('list/fields', getClip(fm));
});
it('filters', async () => {
await loadStore();
const fm: FieldManager = await getEle();
(fm.shadowRoot.querySelector('#search') as TextInput).focus();
fm.query = 'at';
await fm.updateComplete;
expect(fm.featuredFields.length).to.equal(1);
expect(fm.otherFieldKeys.length).to.equal(2);
await assertScreenshot('list/fields-filtered', getClip(fm));
});
it('hovers', async () => {
await loadStore();
const fm: FieldManager = await getEle();
// hover over the first item
const first = fm.shadowRoot.querySelector('.sortable') as HTMLDivElement;
const bounds = first.getBoundingClientRect();
await moveMouse(bounds.left + 20, bounds.top + 10);
await assertScreenshot('list/fields-hovered', getClip(fm));
});
it('drags featured down', async () => {
await loadStore();
const fm: FieldManager = await getEle();
const first = fm.shadowRoot.querySelector('.sortable') as HTMLDivElement;
const bounds = first.getBoundingClientRect();
// drag our item
await moveMouse(bounds.left + 20, bounds.top + 10);
await mouseDown();
await moveMouse(bounds.left + 30, bounds.bottom + 20);
await assertScreenshot('list/fields-dragging', getClip(fm));
});
});