@thednp/shorty 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/shorty.cjs +1 -1
- package/dist/shorty.cjs.map +1 -1
- package/dist/shorty.d.ts +12 -11
- package/dist/shorty.js +1 -1
- package/dist/shorty.js.map +1 -1
- package/dist/shorty.mjs +14 -4
- package/dist/shorty.mjs.map +1 -1
- package/package.json +17 -15
- package/src/boolean/isApple.ts +1 -1
- package/src/boolean/isFirefox.ts +3 -1
- package/src/boolean/isMobile.ts +1 -1
- package/src/event/one.ts +1 -1
- package/src/get/getRectRelativeToOffsetParent.ts +1 -1
- package/src/index.ts +11 -0
- package/src/misc/createCustomEvent.ts +5 -5
- package/src/misc/createElementNS.ts +1 -1
- package/src/misc/emulateAnimationEnd.ts +3 -2
- package/src/misc/emulateTransitionEnd.ts +2 -2
- package/src/selectors/closest.ts +5 -2
- package/test/att.test.ts +43 -0
- package/test/boolean.test.ts +30 -0
- package/test/class.test.ts +26 -0
- package/test/event.test.ts +39 -0
- package/{cypress/test.html → test/fixtures/getExampleDom.ts} +17 -32
- package/test/fixtures/style.css +18 -0
- package/test/get.test.ts +150 -0
- package/{cypress/e2e/is.cy.ts → test/is.test.ts} +77 -74
- package/test/misc.test.ts +352 -0
- package/test/selectors.test.ts +90 -0
- package/tsconfig.json +6 -1
- package/vitest.config-ui.ts +21 -0
- package/vitest.config.ts +20 -0
- package/cypress/e2e/att.cy.ts +0 -46
- package/cypress/e2e/boolean.cy.ts +0 -44
- package/cypress/e2e/class.cy.ts +0 -28
- package/cypress/e2e/event.cy.ts +0 -51
- package/cypress/e2e/get.cy.ts +0 -168
- package/cypress/e2e/misc.cy.ts +0 -354
- package/cypress/e2e/selectors.cy.ts +0 -85
- package/cypress/plugins/esbuild-istanbul.ts +0 -50
- package/cypress/plugins/tsCompile.ts +0 -34
- package/cypress/support/commands.ts +0 -37
- package/cypress/support/e2e.ts +0 -21
- package/cypress/support/index.js +0 -22
- package/cypress.config.ts +0 -30
- /package/{cypress → test}/fixtures/custom-elem.js +0 -0
package/test/get.test.ts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { expect, it, describe, afterEach } from 'vitest';
|
|
2
|
+
import { getExampleDOM } from './fixtures/getExampleDom';
|
|
3
|
+
import * as SHORTY from '../src/index';
|
|
4
|
+
import CustomElem from './fixtures/custom-elem';
|
|
5
|
+
import "./fixtures/style.css";
|
|
6
|
+
|
|
7
|
+
describe('Shorty Library Tests - GET', () => {
|
|
8
|
+
const wrapper = document.createElement('div');
|
|
9
|
+
document.body.append(wrapper);
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
wrapper.innerHTML = '';
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('Test get folder', async () => {
|
|
15
|
+
const container = getExampleDOM();
|
|
16
|
+
wrapper.append(container);
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
getBoundingClientRect,
|
|
20
|
+
getDocument,
|
|
21
|
+
getDocumentBody,
|
|
22
|
+
getDocumentElement,
|
|
23
|
+
getDocumentHead,
|
|
24
|
+
getElementAnimationDelay,
|
|
25
|
+
getElementAnimationDuration,
|
|
26
|
+
getElementTransitionDelay,
|
|
27
|
+
getElementTransitionDuration,
|
|
28
|
+
getElementStyle,
|
|
29
|
+
getNodeScroll,
|
|
30
|
+
getParentNode,
|
|
31
|
+
getRectRelativeToOffsetParent,
|
|
32
|
+
getUID,
|
|
33
|
+
getWindow,
|
|
34
|
+
ObjectValues,
|
|
35
|
+
querySelector
|
|
36
|
+
} = SHORTY;
|
|
37
|
+
const element = querySelector('.alert', container);
|
|
38
|
+
// console.log(element)
|
|
39
|
+
|
|
40
|
+
if (!element) return;
|
|
41
|
+
|
|
42
|
+
// Object.assign(element.style, {width: '860px', height: '110px', top: '85', left: '60' });
|
|
43
|
+
element.style.transform = 'scale(1.01)';
|
|
44
|
+
const win = getWindow(element);
|
|
45
|
+
const CE = new CustomElem();
|
|
46
|
+
CE.className = 'btn btn-outline-primary';
|
|
47
|
+
container.append(CE);
|
|
48
|
+
|
|
49
|
+
// we round values so all browsers return same values
|
|
50
|
+
let { x, y, top, left, right, bottom, width, height } = getBoundingClientRect(
|
|
51
|
+
element,
|
|
52
|
+
true,
|
|
53
|
+
);
|
|
54
|
+
expect(
|
|
55
|
+
ObjectValues([x, y, top, left, right, bottom, width, height] as any).map(Math.round)
|
|
56
|
+
// ).to.deep.equal([63, 87, 87, 63, 927, 204, 864, 117]);
|
|
57
|
+
).to.not.deep.equal([0, 0, 0, 0, 0, 0, 0, 0]);
|
|
58
|
+
element.style.transform = '';
|
|
59
|
+
|
|
60
|
+
expect(getWindow()).toBeDefined(); // root WINDOW
|
|
61
|
+
expect(getWindow(element.ownerDocument)).toBeDefined();
|
|
62
|
+
expect(getWindow(CE)).toBeDefined();
|
|
63
|
+
expect(getWindow(CE.shadowRoot as Node)).toBeDefined();
|
|
64
|
+
expect(getWindow(win.top as unknown as Node)).toBeDefined();
|
|
65
|
+
|
|
66
|
+
expect(getDocument()).toBeDefined();
|
|
67
|
+
expect(getDocument(element)).toBeDefined();
|
|
68
|
+
expect(getDocument(win.document as unknown as Document)).toBeDefined();
|
|
69
|
+
expect(getDocument(win as any)).toBeDefined();
|
|
70
|
+
|
|
71
|
+
expect(getDocumentBody(element)).toBeDefined();
|
|
72
|
+
expect(getDocumentElement(element)).toBeDefined();
|
|
73
|
+
expect(getDocumentHead(element)).toBeDefined();
|
|
74
|
+
|
|
75
|
+
expect(getElementAnimationDelay(element)).to.equal(0);
|
|
76
|
+
expect(getElementAnimationDuration(element)).to.equal(0);
|
|
77
|
+
|
|
78
|
+
CE.style.animation = 'animate-me 1s ease 0.5s';
|
|
79
|
+
expect(getElementAnimationDelay(CE)).to.equal(500);
|
|
80
|
+
expect(getElementAnimationDuration(CE)).to.equal(1000);
|
|
81
|
+
|
|
82
|
+
CE.style.animation = 'animate-me 1200ms ease 400ms';
|
|
83
|
+
expect(getElementAnimationDelay(CE)).to.equal(400);
|
|
84
|
+
|
|
85
|
+
expect(getElementAnimationDuration(CE)).to.equal(1200);
|
|
86
|
+
|
|
87
|
+
element.style.transition = 'opacity .145s linear .1s';
|
|
88
|
+
expect(getElementTransitionDelay(element)).to.equal(100);
|
|
89
|
+
expect(getElementTransitionDuration(element)).to.equal(145);
|
|
90
|
+
|
|
91
|
+
element.style.transition = 'opacity 140ms linear 10ms';
|
|
92
|
+
expect(
|
|
93
|
+
getElementTransitionDelay(element),
|
|
94
|
+
).to.equal(10);
|
|
95
|
+
|
|
96
|
+
expect(
|
|
97
|
+
getElementTransitionDuration(element),
|
|
98
|
+
).to.equal(140);
|
|
99
|
+
|
|
100
|
+
element.style.transition = '';
|
|
101
|
+
|
|
102
|
+
expect(getElementStyle(element, 'color'), 'getElementStyle(color)').to.equal(
|
|
103
|
+
'rgb(102, 77, 3)',
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
expect(getNodeScroll(win)).to.deep.equal({ x: 0, y: 0 });
|
|
107
|
+
expect(getNodeScroll(element), 'getNodeScroll(element)').to.deep.equal({ x: 0, y: 0 });
|
|
108
|
+
expect(
|
|
109
|
+
getNodeScroll(element.offsetParent as HTMLElement),
|
|
110
|
+
'getNodeScroll(element.offsetParent)',
|
|
111
|
+
).to.deep.equal({ x: 0, y: 0 });
|
|
112
|
+
expect(getNodeScroll(getDocumentBody(element)), 'getNodeScroll(body)').to.deep.equal({
|
|
113
|
+
x: 0,
|
|
114
|
+
y: 0,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
expect(getParentNode(getDocumentElement())).to.be.instanceOf(
|
|
118
|
+
HTMLHtmlElement,
|
|
119
|
+
); // root HTML
|
|
120
|
+
expect(getParentNode(win as any)).to.be.instanceOf(HTMLHtmlElement);
|
|
121
|
+
expect(getParentNode(getDocumentBody(element))).to.be.instanceOf(
|
|
122
|
+
HTMLHtmlElement,
|
|
123
|
+
);
|
|
124
|
+
expect(getParentNode(element), 'getParentNode(node)').toBeDefined();
|
|
125
|
+
expect(getParentNode(CE), 'getParentNode(CustomElement)').to.be.instanceOf(
|
|
126
|
+
HTMLDivElement,
|
|
127
|
+
);
|
|
128
|
+
expect(
|
|
129
|
+
getParentNode(CE.shadowRoot!),
|
|
130
|
+
'getParentNode(CustomElement.shadowRoot)',
|
|
131
|
+
).to.be.instanceOf(CustomElem);
|
|
132
|
+
|
|
133
|
+
({ x, y, width, height } = getRectRelativeToOffsetParent(
|
|
134
|
+
element,
|
|
135
|
+
getDocumentElement(win),
|
|
136
|
+
getNodeScroll(getDocumentElement(win)),
|
|
137
|
+
));
|
|
138
|
+
|
|
139
|
+
expect(
|
|
140
|
+
[x, y, width, height].map(Math.round),
|
|
141
|
+
'getRectRelativeToOffsetParent',
|
|
142
|
+
).to.not.deep.equal([0, 0, 0, 0]);
|
|
143
|
+
|
|
144
|
+
expect(getUID(element), 'getUID()').to.eq(0);
|
|
145
|
+
expect(getUID(element, 'Alert'), 'getUID(key) - set & returns').to.eq(0);
|
|
146
|
+
expect(getUID(element, 'Alert'), 'getUID(key) - returns').to.eq(0);
|
|
147
|
+
expect(getUID(win.document.body, 'Alert'), 'getUID(key) - set & returns').to.eq(1);
|
|
148
|
+
expect(getUID(win.document.body, 'Alert'), 'getUID(key) - returns').to.eq(1);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { expect, it, describe, vi, afterEach } from 'vitest';
|
|
2
|
+
import { getExampleDOM } from './fixtures/getExampleDom';
|
|
3
|
+
import * as SHORTY from '../src/index';
|
|
4
|
+
import "./fixtures/style.css";
|
|
5
|
+
|
|
6
|
+
import CustomElem from './fixtures/custom-elem';
|
|
7
|
+
|
|
8
|
+
describe('Shorty Library Tests - IS', () => {
|
|
9
|
+
const wrapper = document.createElement('div');
|
|
10
|
+
document.body.append(wrapper);
|
|
11
|
+
afterEach(async () => {
|
|
12
|
+
wrapper.innerHTML = '';
|
|
12
13
|
});
|
|
13
14
|
|
|
14
15
|
it('Test is folder', () => {
|
|
16
|
+
const container = getExampleDOM();
|
|
17
|
+
wrapper.append(container);
|
|
18
|
+
const win = container.ownerDocument.defaultView!;
|
|
19
|
+
|
|
15
20
|
const {
|
|
16
21
|
isArray,
|
|
17
22
|
isCustomElement,
|
|
@@ -45,78 +50,75 @@ describe('Shorty Library Tests', () => {
|
|
|
45
50
|
// getElementsByTagName,
|
|
46
51
|
} = SHORTY;
|
|
47
52
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const table = querySelector('table', win.document);
|
|
67
|
-
|
|
68
|
-
expect(isArray(new Float32Array(0, 'a')), 'isArray(Float32Array)').to.be.false;
|
|
53
|
+
// const win = getWindow($element[0]);
|
|
54
|
+
const CE1 = new CustomElem();
|
|
55
|
+
CE1.className = 'btn btn-outline-primary';
|
|
56
|
+
CE1.style.transform = 'scale(1.01)';
|
|
57
|
+
document.body.append(CE1);
|
|
58
|
+
|
|
59
|
+
const element = querySelector('.alert', container)!;
|
|
60
|
+
const CE = querySelector('custom-elem', document) as HTMLElement;
|
|
61
|
+
CE.className = 'btn btn-outline-primary';
|
|
62
|
+
// CE.style.transform = 'scale(1.01)';
|
|
63
|
+
// win.document.body.append(CE);
|
|
64
|
+
const img = querySelector('img', element);
|
|
65
|
+
const svg = querySelector('svg', element);
|
|
66
|
+
const path = querySelector('path', element);
|
|
67
|
+
const table = querySelector('table', document);
|
|
68
|
+
|
|
69
|
+
vi.waitFor(() => {
|
|
70
|
+
expect(isArray(new Float32Array(0 as any, 'a' as any))).to.be.false;
|
|
69
71
|
expect(isArray(), 'isArray()').to.be.false;
|
|
70
72
|
expect(isArray(element), 'isArray(node)').to.be.false;
|
|
71
73
|
expect(isArray([0, 'a']), 'isArray([0, 1]])').to.be.true;
|
|
72
|
-
expect(isArray(new Array(0, 'a')), 'isArray(new Array(0, 1)])').to.be.true;
|
|
73
|
-
|
|
74
|
+
expect(isArray(new Array(<any>0, 'a')), 'isArray(new Array(0, 1)])').to.be.true;
|
|
75
|
+
|
|
74
76
|
expect(isDocument(), 'isDocument()').to.be.false;
|
|
75
77
|
expect(isDocument(win), 'isDocument(document)').to.be.false;
|
|
76
78
|
expect(isDocument(document), 'isDocument(document)').to.be.true;
|
|
77
79
|
expect(isDocument(win.document), 'isDocument(document)').to.be.true;
|
|
78
|
-
|
|
80
|
+
|
|
79
81
|
expect(isElement(), 'isElement()').to.be.false;
|
|
80
82
|
expect(isElement(win.document), 'isElement(document)').to.be.false;
|
|
81
83
|
expect(isElement(win), 'isElement(window)').to.be.false;
|
|
82
84
|
expect(isElement(element), 'isElement(node)').to.be.true;
|
|
83
85
|
expect(isElement(win.document.body), 'isElement(body)').to.be.true;
|
|
84
|
-
|
|
86
|
+
|
|
85
87
|
expect(isElementsArray(), 'isElementsArray()').to.be.false;
|
|
86
88
|
expect(isElementsArray(win), 'isElementsArray(window)').to.be.false;
|
|
87
89
|
expect(isElementsArray([0, 1]), 'isElementsArray(window)').to.be.false;
|
|
88
90
|
expect(isElementsArray([...element.children]), 'isElementsArray(expected)').to.be.true;
|
|
89
|
-
|
|
91
|
+
|
|
90
92
|
expect(isFunction(), 'isFunction()').to.be.false;
|
|
91
93
|
expect(isFunction(element), 'isFunction(node)').to.be.false;
|
|
92
94
|
expect(isFunction(element.addEventListener), 'isFunction(function)').to.be.true;
|
|
93
|
-
|
|
95
|
+
|
|
94
96
|
expect(isObject(), 'isObject()').to.be.false;
|
|
95
97
|
expect(isObject(element), 'isObject(node)').to.be.true;
|
|
96
98
|
expect(isObject({ a: 2 }), 'isObject(object)').to.be.true;
|
|
97
99
|
expect(isObject(element.addEventListener), 'isObject(function)').to.be.false;
|
|
98
|
-
|
|
100
|
+
|
|
99
101
|
expect(isHTMLCollection(), 'isHTMLCollection()').to.be.false;
|
|
100
102
|
expect(isHTMLCollection([...element.children]), 'isHTMLCollection(array)').to.be.false;
|
|
101
103
|
expect(isHTMLCollection(element.children), 'isHTMLCollection(expected)').to.be.true;
|
|
102
|
-
|
|
104
|
+
|
|
103
105
|
expect(isHTMLElement(), 'isHTMLElement()').to.be.false;
|
|
104
106
|
expect(isHTMLElement(element), 'isHTMLElement(element)').to.be.true;
|
|
105
107
|
expect(isHTMLElement(win), 'isHTMLElement(window)').to.be.false;
|
|
106
108
|
expect(isHTMLElement(win.document.body), 'isHTMLElement(body)').to.be.true;
|
|
107
109
|
expect(isHTMLElement(win.document.head), 'isHTMLElement(head)').to.be.true;
|
|
108
110
|
expect(isHTMLElement(CE), 'isHTMLElement(CustomElement)').to.be.true;
|
|
109
|
-
expect(isHTMLElement(CE
|
|
111
|
+
expect(isHTMLElement(CE!.shadowRoot), 'isHTMLElement(CustomElement)').to.be.false;
|
|
110
112
|
expect(isHTMLElement([...element.children]), 'isHTMLElement(array)').to.be.false;
|
|
111
113
|
expect(isHTMLElement(win.document), 'isHTMLElement(document)').to.be.false;
|
|
112
|
-
|
|
114
|
+
|
|
113
115
|
expect(isHTMLImageElement(), 'isHTMLImageElement()').to.be.false;
|
|
114
116
|
expect(isHTMLImageElement(win.document), 'isHTMLImageElement(document)').to.be.false;
|
|
115
117
|
expect(isHTMLImageElement(win), 'isHTMLImageElement(window)').to.be.false;
|
|
116
118
|
expect(isHTMLImageElement(img), 'isHTMLImageElement(image)').to.be.true;
|
|
117
119
|
expect(isHTMLImageElement(svg), 'isHTMLImageElement(svg)').to.be.false;
|
|
118
120
|
expect(isHTMLImageElement(path), 'isHTMLImageElement(path)').to.be.false;
|
|
119
|
-
|
|
121
|
+
|
|
120
122
|
expect(isMedia(), 'isMedia()').to.be.false;
|
|
121
123
|
expect(isMedia(win.document), 'isMedia(document)').to.be.false;
|
|
122
124
|
expect(isMedia(win), 'isMedia(window)').to.be.false;
|
|
@@ -124,7 +126,7 @@ describe('Shorty Library Tests', () => {
|
|
|
124
126
|
expect(isMedia(img), 'isMedia(image)').to.be.true;
|
|
125
127
|
expect(isMedia(svg), 'isMedia(svg)').to.be.true;
|
|
126
128
|
expect(isMedia(path), 'isMedia(path)').to.be.true;
|
|
127
|
-
|
|
129
|
+
|
|
128
130
|
expect(isCanvas(), 'isCanvas()').to.be.false;
|
|
129
131
|
expect(isCanvas(win.document), 'isCanvas(document)').to.be.false;
|
|
130
132
|
expect(isCanvas(win), 'isCanvas(window)').to.be.false;
|
|
@@ -132,34 +134,34 @@ describe('Shorty Library Tests', () => {
|
|
|
132
134
|
expect(isCanvas(img), 'isCanvas(image)').to.be.false;
|
|
133
135
|
expect(isCanvas(svg), 'isCanvas(svg)').to.be.false;
|
|
134
136
|
expect(isCanvas(win.document.createElement('canvas')), 'isCanvas(canvas)').to.be.true;
|
|
135
|
-
|
|
137
|
+
|
|
136
138
|
expect(isJSON(), 'isJSON()').to.be.false;
|
|
137
|
-
expect(isJSON(win.document), 'isJSON(document)').to.be.false;
|
|
138
|
-
expect(isJSON(win), 'isJSON(window)').to.be.false;
|
|
139
|
+
expect(isJSON(win.document as any), 'isJSON(document)').to.be.false;
|
|
140
|
+
expect(isJSON(win as any), 'isJSON(window)').to.be.false;
|
|
139
141
|
expect(isJSON('some string'), 'isJSON(JSON)').to.be.false;
|
|
140
142
|
expect(isJSON('{"a":1,"b":2}'), 'isJSON(JSON)').to.be.true;
|
|
141
143
|
expect(isJSON('["a",2]'), 'isJSON(JSON)').to.be.true;
|
|
142
|
-
|
|
144
|
+
|
|
143
145
|
expect(isMap(), 'isMap()').to.be.false;
|
|
144
146
|
expect(isMap(win.document), 'isMap(document)').to.be.false;
|
|
145
147
|
expect(isMap(win), 'isMap(window)').to.be.false;
|
|
146
148
|
expect(isMap(new Map()), 'isMap(Map)').to.be.true;
|
|
147
|
-
|
|
149
|
+
|
|
148
150
|
expect(isWeakMap(), 'isWeakMap()').to.be.false;
|
|
149
151
|
expect(isWeakMap(win.document), 'isWeakMap(document)').to.be.false;
|
|
150
152
|
expect(isWeakMap(win), 'isWeakMap(window)').to.be.false;
|
|
151
153
|
expect(isWeakMap(new WeakMap()), 'isWeakMap(WeakMap)').to.be.true;
|
|
152
|
-
|
|
154
|
+
|
|
153
155
|
expect(isElementInScrollRange(), 'isElementInScrollRange()').to.be.false;
|
|
154
|
-
expect(isElementInScrollRange(win), 'isElementInScrollRange(window)').to.be.false;
|
|
155
|
-
expect(isElementInScrollRange(CE), 'isElementInScrollRange(CustomElement)').to.be.true;
|
|
156
|
+
expect(isElementInScrollRange(win as any), 'isElementInScrollRange(window)').to.be.false;
|
|
157
|
+
expect(isElementInScrollRange(CE!), 'isElementInScrollRange(CustomElement)').to.be.true;
|
|
156
158
|
expect(isElementInScrollRange(element), 'isElementInScrollRange(node)').to.be.true;
|
|
157
|
-
|
|
159
|
+
|
|
158
160
|
expect(isElementInViewport(), 'isElementInScrollRange()').to.be.false;
|
|
159
|
-
expect(isElementInViewport(win), 'isElementInScrollRange(window)').to.be.false;
|
|
160
|
-
expect(isElementInViewport(CE), '
|
|
161
|
+
expect(isElementInViewport(win as any), 'isElementInScrollRange(window)').to.be.false;
|
|
162
|
+
expect(isElementInViewport(CE!), 'isElementInViewport(CustomElement)').to.be.false;
|
|
161
163
|
expect(isElementInViewport(element), 'isElementInScrollRange(node)').to.be.true;
|
|
162
|
-
|
|
164
|
+
|
|
163
165
|
expect(isNode(), 'isNode()').to.be.false;
|
|
164
166
|
expect(isNode(img), 'isNode(image)').to.be.true;
|
|
165
167
|
expect(isNode(svg), 'isNode(svg)').to.be.true;
|
|
@@ -167,22 +169,22 @@ describe('Shorty Library Tests', () => {
|
|
|
167
169
|
expect(isNode(win.document), 'isNode(document)').to.be.true;
|
|
168
170
|
expect(isNode(win), 'isNode(window)').to.be.false;
|
|
169
171
|
expect(isNode(CE), 'isNode(CustomElement)').to.be.true;
|
|
170
|
-
|
|
172
|
+
|
|
171
173
|
expect(isNodeList(), 'isNodeList()').to.be.false;
|
|
172
174
|
expect(isNodeList(element), 'isNodeList(node)').to.be.false;
|
|
173
175
|
expect(isNodeList(element.children), 'isNodeList(HTMLCollection)').to.be.false;
|
|
174
176
|
expect(isNodeList(element.querySelectorAll('*')), 'isNodeList(expected)').to.be.true;
|
|
175
|
-
|
|
177
|
+
|
|
176
178
|
expect(isRTL(), 'isRTL()').to.be.false;
|
|
177
179
|
expect(isRTL(element), 'isRTL(node)').to.be.false;
|
|
178
180
|
expect(isRTL(win.document), 'isRTL(document)').to.be.false;
|
|
179
|
-
|
|
181
|
+
|
|
180
182
|
expect(isScaledElement(), 'isScaledElement()').to.be.false;
|
|
181
183
|
expect(isScaledElement(element), 'isScaledElement(node)').to.be.false;
|
|
182
|
-
expect(isScaledElement(win), 'isScaledElement(window)').to.be.false;
|
|
183
|
-
expect(isScaledElement(win.document), 'isScaledElement(document)').to.be.false;
|
|
184
|
-
expect(isScaledElement(CE), 'isScaledElement(expected)').to.be.true;
|
|
185
|
-
|
|
184
|
+
expect(isScaledElement(win as any), 'isScaledElement(window)').to.be.false;
|
|
185
|
+
expect(isScaledElement(win.document as any), 'isScaledElement(document)').to.be.false;
|
|
186
|
+
expect(isScaledElement(CE!), 'isScaledElement(expected)').to.be.true;
|
|
187
|
+
|
|
186
188
|
expect(isSVGElement(), 'isSVGElement()').to.be.false;
|
|
187
189
|
expect(isSVGElement(element), 'isSVGElement(node)').to.be.false;
|
|
188
190
|
expect(isSVGElement(win), 'isSVGElement(window)').to.be.false;
|
|
@@ -190,36 +192,36 @@ describe('Shorty Library Tests', () => {
|
|
|
190
192
|
expect(isSVGElement(CE), 'isSVGElement(CustomElement)').to.be.false;
|
|
191
193
|
expect(isSVGElement(svg), 'isSVGElement(svg)').to.be.true;
|
|
192
194
|
expect(isSVGElement(path), 'isSVGElement(path)').to.be.true;
|
|
193
|
-
|
|
195
|
+
|
|
194
196
|
expect(isString(), 'isString()').to.be.false;
|
|
195
197
|
expect(isString(element), 'isString(node)').to.be.false;
|
|
196
198
|
expect(isString(element.nodeName), 'isString(nodeName)').to.be.true;
|
|
197
199
|
expect(isString(element.nodeType), 'isString(number)').to.be.false;
|
|
198
|
-
|
|
200
|
+
|
|
199
201
|
expect(isNumber(), 'isNumber()').to.be.false;
|
|
200
202
|
expect(isNumber(element), 'isNumber(node)').to.be.false;
|
|
201
203
|
expect(isNumber(element.nodeName), 'isNumber(nodeName)').to.be.false;
|
|
202
204
|
expect(isNumber(element.nodeType), 'isNumber(nodeType)').to.be.true;
|
|
203
205
|
expect(isNumber(0.55), 'isNumber(number)').to.be.true;
|
|
204
206
|
expect(isNumber(-Infinity), 'isNumber(Infinity)').to.be.true;
|
|
205
|
-
|
|
207
|
+
|
|
206
208
|
expect(isTableElement(), 'isTableElement()').to.be.false;
|
|
207
209
|
expect(isTableElement(element), 'isTableElement(node)').to.be.false;
|
|
208
210
|
expect(isTableElement(win), 'isTableElement(window)').to.be.false;
|
|
209
211
|
expect(isTableElement(win.document), 'isTableElement(document)').to.be.false;
|
|
210
212
|
expect(isTableElement(CE), 'isTableElement(CustomElement)').to.be.false;
|
|
211
213
|
expect(isTableElement(table), 'isTableElement(table)').to.be.true;
|
|
212
|
-
expect(isTableElement(querySelector('td', table)), 'isTableElement(TD)').to.be.true;
|
|
213
|
-
expect(isTableElement(querySelector('th', table)), 'isTableElement(TH)').to.be.true;
|
|
214
|
-
|
|
214
|
+
expect(isTableElement(querySelector('td', table!)), 'isTableElement(TD)').to.be.true;
|
|
215
|
+
expect(isTableElement(querySelector('th', table!)), 'isTableElement(TH)').to.be.true;
|
|
216
|
+
|
|
215
217
|
expect(isWindow(), 'isWindow()').to.be.false;
|
|
216
218
|
expect(isWindow(win.document), 'isWindow(document)').to.be.false;
|
|
217
219
|
expect(isWindow(document), 'isWindow(document)').to.be.false;
|
|
218
|
-
expect(isWindow(win), '
|
|
219
|
-
expect(isWindow(win.top), '
|
|
220
|
+
expect(isWindow(win), 'isWindow(window)').to.be.true;
|
|
221
|
+
expect(isWindow(win.top), 'isWindow(window)').to.be.true;
|
|
220
222
|
expect(isWindow(window), 'isDocument(window)').to.be.true;
|
|
221
223
|
expect(isWindow(window.top), 'isDocument(window)').to.be.true;
|
|
222
|
-
|
|
224
|
+
|
|
223
225
|
expect(isCustomElement(), 'isCustomElement()').to.be.false;
|
|
224
226
|
expect(isCustomElement(element), 'isCustomElement(node)').to.be.false;
|
|
225
227
|
expect(isCustomElement(CE), 'isCustomElement(CustomElement)').to.be.true;
|
|
@@ -227,7 +229,8 @@ describe('Shorty Library Tests', () => {
|
|
|
227
229
|
expect(isShadowRoot(), 'isShadowRoot()').to.be.false;
|
|
228
230
|
expect(isShadowRoot(element), 'isShadowRoot(element)').to.be.false;
|
|
229
231
|
expect(isShadowRoot(document), 'isShadowRoot(document)').to.be.false;
|
|
230
|
-
expect(isShadowRoot(CE
|
|
231
|
-
|
|
232
|
+
expect(isShadowRoot(CE!.shadowRoot), 'isShadowRoot(CustomElement.shadowRoot)').to.be.true;
|
|
233
|
+
|
|
234
|
+
}, { timeout: 150 })
|
|
232
235
|
});
|
|
233
236
|
});
|