-
Notifications
You must be signed in to change notification settings - Fork 7
/
temba-contact-fields.test.ts
54 lines (44 loc) · 1.59 KB
/
temba-contact-fields.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
import { assert, expect } from '@open-wc/testing';
import { ContactFields } from '../src/contacts/ContactFields';
import { delay, getComponent, loadStore, mockPOST } from './utils.test';
const TAG = 'temba-contact-fields';
const getFields = async (attrs: any = {}) => {
attrs['endpoint'] = '/test-assets/contacts/';
const fields = (await getComponent(TAG, attrs, '', 600)) as ContactFields;
// wait for our contact to load
await delay(100);
return fields;
};
describe(TAG, () => {
it('renders default', async () => {
// we are a StoreElement, so load a store first
await loadStore();
const fields: ContactFields = await getFields({
contact: 'contact-dave-active'
});
assert.instanceOf(fields, ContactFields);
// await assertScreenshot('contacts/fields', getClip(fields));
});
it('handles updated contacts properly', async () => {
await loadStore();
const fields: ContactFields = await getFields({
contact: 'contact-dave-active'
});
const data = fields.data;
data.groups.forEach((group) => {
delete group['is_dynamic'];
});
mockPOST(/api\/v2\/contacts\.json\?uuid=contact-dave-active/, data);
// update our fields
await typeInto(
"temba-contact-fields:temba-contact-field[key='age']:temba-textinput",
'62',
true,
true
);
// the updated contact should still have is_dynamic flags added
expect(fields.data.groups[0].is_dynamic).equals(true);
expect(fields.data.groups[1].is_dynamic).equals(false);
// await assertScreenshot('contacts/fields-updated', getClip(fields));
});
});