-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheditv2.spec.ts
More file actions
58 lines (46 loc) · 1.63 KB
/
editv2.spec.ts
File metadata and controls
58 lines (46 loc) · 1.63 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
53
54
55
56
57
58
import { expect } from '@open-wc/testing';
import { Update } from './editv1.js';
import {
Insert,
isEditV2,
Remove,
SetAttributes,
SetTextContent,
} from './editv2.js';
const element = new DOMParser().parseFromString(
'<SCL />',
'application/xml',
)!.documentElement;
const update: Update = {
element,
attributes: {
attr1: { namespaceURI: 'http://myns.com', value: 'new value' },
},
};
const insert: Insert = { parent: element, node: element, reference: null };
const remove: Remove = { node: element };
const setAttributes: SetAttributes = {
element,
attributes: { name: 'value' },
attributesNS: { namespaceURI: { name: 'value' } },
};
const setTextContent: SetTextContent = { element, textContent: '' };
describe('isEditV2', () => {
it('returns false for invalid Edit type', () =>
expect('invalid edit').to.not.satisfy(isEditV2));
it('returns false for Update', () => expect(update).to.not.satisfy(isEditV2));
it('returns true for Insert', () => expect(insert).to.satisfy(isEditV2));
it('returns true for Remove', () => expect(remove).to.satisfy(isEditV2));
it('returns true for SetAttributes', () =>
expect(setAttributes).to.satisfy(isEditV2));
it('returns true for SetTextContent', () =>
expect(setTextContent).to.satisfy(isEditV2));
it('returns false for a mixed edit and editV2 array', () =>
expect([update, setAttributes]).to.not.satisfy(isEditV2));
it('returns false for edit array', () =>
expect([update, update]).to.not.satisfy(isEditV2));
it('returns true for editV2 array', () =>
expect([setAttributes, remove, insert, setTextContent]).to.satisfy(
isEditV2,
));
});