@neovici/cosmoz-queue 1.6.0 → 1.6.1
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.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { assert, oneEvent } from '@open-wc/testing';
|
|
2
2
|
import { oneDefaultPreventedEvent } from '@open-wc/testing-helpers';
|
|
3
3
|
import { itemClick } from '../item-click';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
describe('item-click', () => {
|
|
5
|
+
it('fires event', async () => {
|
|
6
6
|
const el = document.createElement('div');
|
|
7
7
|
el.addEventListener('click', itemClick({ index: 2, activate: 'queue' }));
|
|
8
8
|
setTimeout(() => el.click());
|
|
@@ -10,7 +10,7 @@ suite('item-click', () => {
|
|
|
10
10
|
assert.equal(detail.index, 2);
|
|
11
11
|
assert.equal(detail.activate, 'queue');
|
|
12
12
|
});
|
|
13
|
-
|
|
13
|
+
it('prevents default', async () => {
|
|
14
14
|
const el = document.createElement('div');
|
|
15
15
|
const ev = new MouseEvent('click');
|
|
16
16
|
el.addEventListener('click', itemClick({ index: 3, activate: 'list' }));
|
|
@@ -19,7 +19,7 @@ suite('item-click', () => {
|
|
|
19
19
|
assert.equal(detail.index, 3);
|
|
20
20
|
assert.equal(detail.activate, 'list');
|
|
21
21
|
});
|
|
22
|
-
|
|
22
|
+
it('does not fire event', async () => {
|
|
23
23
|
const el = document.createElement('div');
|
|
24
24
|
const ev = new MouseEvent('click', { ctrlKey: true });
|
|
25
25
|
el.addEventListener('click', itemClick({ index: 3, activate: 'list' }));
|
|
@@ -2,15 +2,15 @@ import { expect, fixture } from '@open-wc/testing';
|
|
|
2
2
|
import { nothing } from 'lit-html';
|
|
3
3
|
import { spy } from 'sinon';
|
|
4
4
|
import { renderNav, renderPagination } from '../render';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
describe('queue > render', () => {
|
|
6
|
+
it('renderNav', async () => {
|
|
7
7
|
const el = await fixture(renderNav({}));
|
|
8
8
|
await expect(el).dom.to.equalSnapshot();
|
|
9
9
|
});
|
|
10
|
-
|
|
10
|
+
it('renderPagination nothing', async () => {
|
|
11
11
|
expect(renderPagination()).to.equal(nothing);
|
|
12
12
|
});
|
|
13
|
-
|
|
13
|
+
it('renderPagination', async () => {
|
|
14
14
|
const onPage = spy();
|
|
15
15
|
const el = await fixture(renderPagination({
|
|
16
16
|
totalPages: 10,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { renderHook } from '@neovici/testing';
|
|
2
2
|
import { assert } from '@open-wc/testing';
|
|
3
3
|
import { usePref } from '../use-pref';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
describe('use-pref', () => {
|
|
5
|
+
it('default pref', async () => {
|
|
6
6
|
const { result } = await renderHook(() => usePref('some', 'asdad'));
|
|
7
7
|
assert.equal(result.current[0], 'asdad');
|
|
8
8
|
});
|
|
9
|
-
|
|
9
|
+
it('update pref', async () => {
|
|
10
10
|
const { result, nextUpdate } = await renderHook(() => usePref('somethingelse'));
|
|
11
11
|
assert.equal(result.current[0], undefined);
|
|
12
12
|
setTimeout(() => result.current[1]('dads'));
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { assert } from '@open-wc/testing';
|
|
2
2
|
import { get, normalize, split } from '../path';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
describe('path', () => {
|
|
4
|
+
describe('normalize', () => {
|
|
5
|
+
it('returns string path as-is', () => {
|
|
6
6
|
assert.equal(normalize('foo.bar.0.baz'), 'foo.bar.0.baz');
|
|
7
7
|
});
|
|
8
|
-
|
|
8
|
+
it('returns empty string as-is', () => {
|
|
9
9
|
assert.equal(normalize(''), '');
|
|
10
10
|
});
|
|
11
|
-
|
|
11
|
+
it('converts array path to flattened string', () => {
|
|
12
12
|
assert.equal(normalize(['foo.bar', 0, 'baz']), 'foo.bar.0.baz');
|
|
13
13
|
});
|
|
14
|
-
|
|
14
|
+
it('handles array with single element', () => {
|
|
15
15
|
assert.equal(normalize(['foo']), 'foo');
|
|
16
16
|
});
|
|
17
|
-
|
|
17
|
+
it('handles array with dotted strings and numbers', () => {
|
|
18
18
|
assert.equal(normalize(['a.b', 1, 'c.d', 2]), 'a.b.1.c.d.2');
|
|
19
19
|
});
|
|
20
|
-
|
|
20
|
+
it('handles empty array', () => {
|
|
21
21
|
assert.equal(normalize([]), '');
|
|
22
22
|
});
|
|
23
23
|
});
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
describe('split', () => {
|
|
25
|
+
it('splits string path into array', () => {
|
|
26
26
|
assert.deepEqual(split('foo.bar.0.baz'), ['foo', 'bar', '0', 'baz']);
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
it('splits array path into flat array', () => {
|
|
29
29
|
assert.deepEqual(split(['foo.bar', 0, 'baz']), [
|
|
30
30
|
'foo',
|
|
31
31
|
'bar',
|
|
@@ -33,54 +33,54 @@ suite('path', () => {
|
|
|
33
33
|
'baz',
|
|
34
34
|
]);
|
|
35
35
|
});
|
|
36
|
-
|
|
36
|
+
it('handles single segment string', () => {
|
|
37
37
|
assert.deepEqual(split('foo'), ['foo']);
|
|
38
38
|
});
|
|
39
|
-
|
|
39
|
+
it('handles array with single element', () => {
|
|
40
40
|
assert.deepEqual(split(['foo']), ['foo']);
|
|
41
41
|
});
|
|
42
|
-
|
|
42
|
+
it('handles empty string', () => {
|
|
43
43
|
assert.deepEqual(split(''), ['']);
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
describe('get', () => {
|
|
47
|
+
it('retrieves nested value with string path', () => {
|
|
48
48
|
const obj = { foo: { bar: { baz: 'value' } } };
|
|
49
49
|
assert.equal(get(obj, 'foo.bar.baz'), 'value');
|
|
50
50
|
});
|
|
51
|
-
|
|
51
|
+
it('retrieves nested value with array path', () => {
|
|
52
52
|
const obj = { foo: { bar: { baz: 'value' } } };
|
|
53
53
|
assert.equal(get(obj, ['foo', 'bar', 'baz']), 'value');
|
|
54
54
|
});
|
|
55
|
-
|
|
55
|
+
it('retrieves nested value with dotted string in array path', () => {
|
|
56
56
|
const obj = { foo: { bar: { baz: 'value' } } };
|
|
57
57
|
assert.equal(get(obj, ['foo.bar', 'baz']), 'value');
|
|
58
58
|
});
|
|
59
|
-
|
|
59
|
+
it('retrieves array element by index', () => {
|
|
60
60
|
const obj = { items: ['a', 'b', 'c'] };
|
|
61
61
|
assert.equal(get(obj, 'items.1'), 'b');
|
|
62
62
|
});
|
|
63
|
-
|
|
63
|
+
it('retrieves array element with array path', () => {
|
|
64
64
|
const obj = { items: ['a', 'b', 'c'] };
|
|
65
65
|
assert.equal(get(obj, ['items', 0]), 'a');
|
|
66
66
|
});
|
|
67
|
-
|
|
67
|
+
it('returns undefined for non-existent path', () => {
|
|
68
68
|
const obj = { foo: { bar: 'value' } };
|
|
69
69
|
assert.equal(get(obj, 'foo.baz.qux'), undefined);
|
|
70
70
|
});
|
|
71
|
-
|
|
71
|
+
it('returns undefined when intermediate property is undefined', () => {
|
|
72
72
|
const obj = { foo: undefined };
|
|
73
73
|
assert.equal(get(obj, 'foo.bar'), undefined);
|
|
74
74
|
});
|
|
75
|
-
|
|
75
|
+
it('returns undefined when intermediate property is null', () => {
|
|
76
76
|
const obj = { foo: null };
|
|
77
77
|
assert.equal(get(obj, 'foo.bar'), undefined);
|
|
78
78
|
});
|
|
79
|
-
|
|
79
|
+
it('returns undefined with empty string path', () => {
|
|
80
80
|
const obj = { foo: 'bar' };
|
|
81
81
|
assert.equal(get(obj, ''), undefined);
|
|
82
82
|
});
|
|
83
|
-
|
|
83
|
+
it('handles complex nested structure', () => {
|
|
84
84
|
const obj = {
|
|
85
85
|
users: [
|
|
86
86
|
{ name: 'Alice', address: { city: 'NYC' } },
|
|
@@ -89,10 +89,10 @@ suite('path', () => {
|
|
|
89
89
|
};
|
|
90
90
|
assert.equal(get(obj, 'users.1.address.city'), 'LA');
|
|
91
91
|
});
|
|
92
|
-
|
|
92
|
+
it('returns undefined for null root', () => {
|
|
93
93
|
assert.equal(get(null, 'foo'), undefined);
|
|
94
94
|
});
|
|
95
|
-
|
|
95
|
+
it('returns undefined for undefined root', () => {
|
|
96
96
|
assert.equal(get(undefined, 'foo'), undefined);
|
|
97
97
|
});
|
|
98
98
|
});
|