@enact/spotlight 3.4.9-experimental-3 → 3.4.9-experimental-7
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/{build/Accelerator → Accelerator}/Accelerator.d.ts +0 -0
- package/Accelerator/Accelerator.js +149 -156
- package/CHANGELOG.md +22 -0
- package/{build/Pause → Pause}/Pause.d.ts +0 -0
- package/Pause/Pause.js +102 -80
- package/Pause/tests/Pause-specs.js +65 -97
- package/SpotlightContainerDecorator/SpotlightContainer.js +175 -140
- package/{build/SpotlightContainerDecorator → SpotlightContainerDecorator}/SpotlightContainerDecorator.d.ts +0 -0
- package/SpotlightContainerDecorator/SpotlightContainerDecorator.js +222 -176
- package/SpotlightContainerDecorator/tests/Element.prototype.closest.js +44 -40
- package/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +221 -210
- package/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +150 -243
- package/SpotlightContainerDecorator/useSpotlightContainer.js +47 -28
- package/{build/SpotlightRootDecorator → SpotlightRootDecorator}/SpotlightRootDecorator.d.ts +0 -0
- package/SpotlightRootDecorator/SpotlightRootDecorator.js +206 -111
- package/{build/Spottable → Spottable}/Spottable.d.ts +0 -0
- package/Spottable/Spottable.js +448 -410
- package/Spottable/tests/Spottable-specs.js +90 -117
- package/package.json +3 -2
- package/src/container.js +718 -653
- package/src/navigate.js +406 -491
- package/src/pointer.js +86 -78
- package/{build/src → src}/spotlight.d.ts +0 -0
- package/src/spotlight.js +846 -885
- package/src/target.js +448 -474
- package/src/tests/container-specs.js +643 -1251
- package/src/tests/navigate-specs.js +77 -134
- package/src/tests/pointer-specs.js +126 -182
- package/src/tests/spotlight-specs.js +103 -133
- package/src/tests/target-specs.js +597 -960
- package/src/tests/utils.js +89 -67
- package/src/utils.js +155 -158
- package/build/Accelerator/Accelerator.js +0 -162
- package/build/Accelerator/package.json +0 -3
- package/build/CHANGELOG.md +0 -838
- package/build/Pause/Pause.js +0 -164
- package/build/Pause/package.json +0 -3
- package/build/Pause/tests/Pause-specs.js +0 -65
- package/build/README.md +0 -61
- package/build/SpotlightContainerDecorator/SpotlightContainer.js +0 -176
- package/build/SpotlightContainerDecorator/SpotlightContainerDecorator.js +0 -282
- package/build/SpotlightContainerDecorator/package.json +0 -3
- package/build/SpotlightContainerDecorator/tests/Element.prototype.closest.js +0 -45
- package/build/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +0 -221
- package/build/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +0 -160
- package/build/SpotlightContainerDecorator/useSpotlightContainer.js +0 -133
- package/build/SpotlightRootDecorator/SpotlightRootDecorator.js +0 -189
- package/build/SpotlightRootDecorator/package.json +0 -3
- package/build/Spottable/Spottable.js +0 -491
- package/build/Spottable/package.json +0 -3
- package/build/Spottable/tests/Spottable-specs.js +0 -90
- package/build/package-lock.json +0 -229
- package/build/package.json +0 -28
- package/build/src/container.js +0 -1201
- package/build/src/navigate.js +0 -419
- package/build/src/pointer.js +0 -183
- package/build/src/spotlight.js +0 -896
- package/build/src/target.js +0 -507
- package/build/src/tests/container-specs.js +0 -653
- package/build/src/tests/navigate-specs.js +0 -87
- package/build/src/tests/pointer-specs.js +0 -130
- package/build/src/tests/spotlight-specs.js +0 -112
- package/build/src/tests/target-specs.js +0 -614
- package/build/src/tests/utils.js +0 -104
- package/build/src/utils.js +0 -180
- package/build/styles/debug.less +0 -97
- package/build/styles/mixins.less +0 -63
- package/docs/index.md +0 -364
|
@@ -1,653 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _container17 = require("../container");
|
|
4
|
-
|
|
5
|
-
var _utils = require("./utils");
|
|
6
|
-
|
|
7
|
-
var _node, _container, _container2, _container3, _container4, _container5, _container6, _container7, _container8, _container9, _container10, _container11, _container12, _container13, _container15, _container16;
|
|
8
|
-
|
|
9
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
-
|
|
11
|
-
var nonSpottable = function nonSpottable() {
|
|
12
|
-
return (0, _utils.node)({
|
|
13
|
-
className: 'other'
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
var scenarios = {
|
|
18
|
-
onlySpottables: (0, _utils.someSpottables)(5),
|
|
19
|
-
onlyContainers: (0, _utils.someContainers)(5),
|
|
20
|
-
spottableAndContainers: (0, _utils.someSpottablesAndContainers)(5),
|
|
21
|
-
nonSpottableSiblings: (0, _utils.join)((0, _utils.someSpottables)(5), (0, _utils.someNodes)(nonSpottable, 5)),
|
|
22
|
-
nestedContainers: (0, _utils.container)((0, _utils.container)((0, _utils.container)())),
|
|
23
|
-
disabledContainers: (0, _utils.join)((0, _utils.someSpottables)(5), (0, _utils.someContainers)(5), (0, _utils.node)((_node = {}, _defineProperty(_node, _container17.containerAttribute, 'disabled-container'), _defineProperty(_node, 'data-spotlight-container-disabled', true), _node))),
|
|
24
|
-
nestedContainersWithSpottables: (0, _utils.join)((0, _utils.someSpottables)(5), (0, _utils.container)({
|
|
25
|
-
children: (0, _utils.someSpottables)(5)
|
|
26
|
-
})),
|
|
27
|
-
siblingContainers: (0, _utils.join)((0, _utils.container)((_container = {}, _defineProperty(_container, _container17.containerAttribute, 'first'), _defineProperty(_container, "children", (0, _utils.someSpottables)(5)), _container)), (0, _utils.container)((_container2 = {}, _defineProperty(_container2, _container17.containerAttribute, 'second'), _defineProperty(_container2, "children", (0, _utils.someSpottables)(5)), _container2))),
|
|
28
|
-
mixedOrder: (0, _utils.join)((0, _utils.container)((_container3 = {}, _defineProperty(_container3, _container17.containerAttribute, 'first'), _defineProperty(_container3, "name", 'c1'), _container3)), (0, _utils.spottable)({
|
|
29
|
-
name: 's1'
|
|
30
|
-
}), (0, _utils.container)((_container4 = {}, _defineProperty(_container4, _container17.containerAttribute, 'second'), _defineProperty(_container4, "name", 'c2'), _container4)), (0, _utils.spottable)({
|
|
31
|
-
name: 's2'
|
|
32
|
-
})),
|
|
33
|
-
complexTree: (0, _utils.join)((0, _utils.spottable)(nonSpottable()), (0, _utils.container)((_container7 = {}, _defineProperty(_container7, _container17.containerAttribute, 'first-container'), _defineProperty(_container7, "children", (0, _utils.join)((0, _utils.someSpottables)(2), (0, _utils.container)((_container6 = {}, _defineProperty(_container6, _container17.containerAttribute, 'second-container'), _defineProperty(_container6, "children", (0, _utils.join)((0, _utils.spottable)({
|
|
34
|
-
id: 'secondContainerFirstSpottable'
|
|
35
|
-
}), (0, _utils.someSpottables)(2), (0, _utils.container)((_container5 = {}, _defineProperty(_container5, _container17.containerAttribute, 'third-container'), _defineProperty(_container5, 'data-spotlight-container-disabled', true), _defineProperty(_container5, "children", (0, _utils.join)((0, _utils.someSpottables)(4), (0, _utils.node)({
|
|
36
|
-
id: 'child-of-third'
|
|
37
|
-
}))), _container5)))), _container6)))), _container7))),
|
|
38
|
-
spottablesInDisabledContainer: (0, _utils.container)((_container8 = {}, _defineProperty(_container8, _container17.containerAttribute, 'container'), _defineProperty(_container8, 'data-spotlight-container-disabled', true), _defineProperty(_container8, "children", (0, _utils.someSpottables)(5)), _container8)),
|
|
39
|
-
spottablesInNestedDisabledContainer: (0, _utils.container)((_container10 = {}, _defineProperty(_container10, _container17.containerAttribute, 'container'), _defineProperty(_container10, 'data-spotlight-container-disabled', true), _defineProperty(_container10, "children", (0, _utils.container)((_container9 = {}, _defineProperty(_container9, _container17.containerAttribute, 'child'), _defineProperty(_container9, "children", (0, _utils.someSpottables)(5)), _container9))), _container10)),
|
|
40
|
-
containerWithDefaultAndLastFocused: (0, _utils.container)((_container11 = {}, _defineProperty(_container11, _container17.containerAttribute, 'container'), _defineProperty(_container11, "children", (0, _utils.join)((0, _utils.spottable)({
|
|
41
|
-
id: 'firstSpottable'
|
|
42
|
-
}), (0, _utils.someSpottables)(5), (0, _utils.node)({
|
|
43
|
-
id: 'spottableDefault',
|
|
44
|
-
className: 'spottable spottable-default'
|
|
45
|
-
}), (0, _utils.spottable)({
|
|
46
|
-
id: 'lastFocused'
|
|
47
|
-
}))), _container11)),
|
|
48
|
-
nestedContainersWithDefaultAndLastFocused: (0, _utils.container)((_container13 = {}, _defineProperty(_container13, _container17.containerAttribute, 'container'), _defineProperty(_container13, "children", (0, _utils.join)((0, _utils.spottable)({
|
|
49
|
-
id: 'firstSpottable'
|
|
50
|
-
}), (0, _utils.someSpottables)(5), (0, _utils.container)((_container12 = {}, _defineProperty(_container12, _container17.containerAttribute, 'child'), _defineProperty(_container12, "id", 'spottableDefault'), _defineProperty(_container12, "className", 'spottable-default'), _defineProperty(_container12, "children", (0, _utils.join)((0, _utils.spottable)({
|
|
51
|
-
id: 'firstChildSpottable'
|
|
52
|
-
}), (0, _utils.someSpottables)(5), (0, _utils.spottable)({
|
|
53
|
-
id: 'lastChildFocused'
|
|
54
|
-
}))), _container12)), (0, _utils.spottable)({
|
|
55
|
-
id: 'lastFocused'
|
|
56
|
-
}))), _container13)),
|
|
57
|
-
emptySubcontainer: (0, _utils.container)((_container15 = {}, _defineProperty(_container15, _container17.containerAttribute, 'container'), _defineProperty(_container15, "children", (0, _utils.join)((0, _utils.container)(_defineProperty({}, _container17.containerAttribute, 'subcontainer')), (0, _utils.spottable)({
|
|
58
|
-
id: 'afterSubcontainer'
|
|
59
|
-
}))), _container15)),
|
|
60
|
-
owned: (0, _utils.join)((0, _utils.spottable)({
|
|
61
|
-
id: 's1'
|
|
62
|
-
}), (0, _utils.node)({
|
|
63
|
-
id: 'n1'
|
|
64
|
-
}), (0, _utils.container)((_container16 = {}, _defineProperty(_container16, _container17.containerAttribute, 'container'), _defineProperty(_container16, 'aria-owns', 's1 n1'), _defineProperty(_container16, "children", (0, _utils.spottable)({
|
|
65
|
-
id: 's2'
|
|
66
|
-
})), _container16)))
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
var setupContainers = function setupContainers() {
|
|
70
|
-
(0, _container17.configureDefaults)({
|
|
71
|
-
selector: '.spottable'
|
|
72
|
-
});
|
|
73
|
-
(0, _container17.configureContainer)(_container17.rootContainerId);
|
|
74
|
-
(0, _container17.setLastContainer)(_container17.rootContainerId);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
var teardownContainers = function teardownContainers() {
|
|
78
|
-
// clean up any containers we create for safe tests
|
|
79
|
-
(0, _container17.removeAllContainers)();
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
describe('container', function () {
|
|
83
|
-
describe('#getSpottableDescendants', function () {
|
|
84
|
-
beforeEach(setupContainers);
|
|
85
|
-
afterEach(teardownContainers);
|
|
86
|
-
test('should find spottables', (0, _utils.testScenario)(scenarios.onlySpottables, function () {
|
|
87
|
-
var expected = 5;
|
|
88
|
-
var actual = (0, _container17.getSpottableDescendants)(_container17.rootContainerId).length;
|
|
89
|
-
expect(actual).toBe(expected);
|
|
90
|
-
}));
|
|
91
|
-
test('should find containers', (0, _utils.testScenario)(scenarios.onlyContainers, function () {
|
|
92
|
-
var expected = 5;
|
|
93
|
-
var actual = (0, _container17.getSpottableDescendants)(_container17.rootContainerId).length;
|
|
94
|
-
expect(actual).toBe(expected);
|
|
95
|
-
}));
|
|
96
|
-
test('should find spottables and containers', (0, _utils.testScenario)(scenarios.spottableAndContainers, function () {
|
|
97
|
-
var expected = 10;
|
|
98
|
-
var actual = (0, _container17.getSpottableDescendants)(_container17.rootContainerId).length;
|
|
99
|
-
expect(actual).toBe(expected);
|
|
100
|
-
}));
|
|
101
|
-
test('should only find spottables with non-spottable siblings', (0, _utils.testScenario)(scenarios.nonSpottableSiblings, function () {
|
|
102
|
-
var expected = 5;
|
|
103
|
-
var actual = (0, _container17.getSpottableDescendants)(_container17.rootContainerId).length;
|
|
104
|
-
expect(actual).toBe(expected);
|
|
105
|
-
}));
|
|
106
|
-
test('should only find top-level containers', (0, _utils.testScenario)(scenarios.nestedContainers, function () {
|
|
107
|
-
var expected = 1;
|
|
108
|
-
var actual = (0, _container17.getSpottableDescendants)(_container17.rootContainerId).length;
|
|
109
|
-
expect(actual).toBe(expected);
|
|
110
|
-
}));
|
|
111
|
-
test('should only find top-level containers and spottables', (0, _utils.testScenario)(scenarios.nestedContainersWithSpottables, function () {
|
|
112
|
-
var expected = 6;
|
|
113
|
-
var actual = (0, _container17.getSpottableDescendants)(_container17.rootContainerId).length;
|
|
114
|
-
expect(actual).toBe(expected);
|
|
115
|
-
}));
|
|
116
|
-
test('should not find spottables in sibling containers', (0, _utils.testScenario)(scenarios.siblingContainers, function () {
|
|
117
|
-
(0, _container17.configureContainer)('first');
|
|
118
|
-
var expected = 5;
|
|
119
|
-
var actual = (0, _container17.getSpottableDescendants)('first').length;
|
|
120
|
-
expect(actual).toBe(expected);
|
|
121
|
-
}));
|
|
122
|
-
test('should not find spottables in descendant containers', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
123
|
-
(0, _container17.configureContainer)('first-container');
|
|
124
|
-
var expected = 3;
|
|
125
|
-
var actual = (0, _container17.getSpottableDescendants)('first-container').length;
|
|
126
|
-
expect(actual).toBe(expected);
|
|
127
|
-
}));
|
|
128
|
-
test('should not find containers that are disabled', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
129
|
-
(0, _container17.configureContainer)('first-container');
|
|
130
|
-
(0, _container17.configureContainer)('second-container');
|
|
131
|
-
var expected = 3;
|
|
132
|
-
var actual = (0, _container17.getSpottableDescendants)('second-container').length;
|
|
133
|
-
expect(actual).toBe(expected);
|
|
134
|
-
}));
|
|
135
|
-
test('should not any spottables within a disabled container', (0, _utils.testScenario)(scenarios.spottablesInDisabledContainer, function () {
|
|
136
|
-
(0, _container17.configureContainer)('container');
|
|
137
|
-
var expected = 0;
|
|
138
|
-
var actual = (0, _container17.getSpottableDescendants)('container').length;
|
|
139
|
-
expect(actual).toBe(expected);
|
|
140
|
-
}));
|
|
141
|
-
test('should not any spottables within a disabled ancestor container', (0, _utils.testScenario)(scenarios.spottablesInNestedDisabledContainer, function () {
|
|
142
|
-
(0, _container17.configureContainer)('container');
|
|
143
|
-
(0, _container17.configureContainer)('child');
|
|
144
|
-
var expected = 0;
|
|
145
|
-
var actual = (0, _container17.getSpottableDescendants)('child').length;
|
|
146
|
-
expect(actual).toBe(expected);
|
|
147
|
-
}));
|
|
148
|
-
test('should return spottables and containers in source order', (0, _utils.testScenario)(scenarios.mixedOrder, function () {
|
|
149
|
-
var expected = ['c1', 's1', 'c2', 's2'];
|
|
150
|
-
var actual = (0, _container17.getSpottableDescendants)(_container17.rootContainerId).map(function (n) {
|
|
151
|
-
return n.getAttribute('name');
|
|
152
|
-
});
|
|
153
|
-
expect(actual).toEqual(expected);
|
|
154
|
-
}));
|
|
155
|
-
test('should include owned nodes', (0, _utils.testScenario)(scenarios.owned, function () {
|
|
156
|
-
(0, _container17.configureContainer)('container'); // owned nodes follow internal nodes
|
|
157
|
-
|
|
158
|
-
var expected = ['s2', 's1'];
|
|
159
|
-
var actual = (0, _container17.getSpottableDescendants)('container').map(function (n) {
|
|
160
|
-
return n.getAttribute('id');
|
|
161
|
-
});
|
|
162
|
-
expect(actual).toEqual(expected);
|
|
163
|
-
}));
|
|
164
|
-
});
|
|
165
|
-
describe('#getContainersForNode', function () {
|
|
166
|
-
test('should return the rootContainerId when no other containers exist', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
|
|
167
|
-
var expected = [_container17.rootContainerId];
|
|
168
|
-
var actual = (0, _container17.getContainersForNode)(root.lastChild);
|
|
169
|
-
expect(actual).toEqual(expected);
|
|
170
|
-
}));
|
|
171
|
-
test('should return all ancestor container ids', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
172
|
-
var childOfThird = root.querySelector('#child-of-third');
|
|
173
|
-
var expected = [_container17.rootContainerId, 'first-container', 'second-container', 'third-container'];
|
|
174
|
-
var actual = (0, _container17.getContainersForNode)(childOfThird);
|
|
175
|
-
expect(actual).toEqual(expected);
|
|
176
|
-
}));
|
|
177
|
-
test('should return immediate container id as last in list', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
178
|
-
var childOfThird = root.querySelector('#child-of-third');
|
|
179
|
-
var expected = 'third-container';
|
|
180
|
-
var actual = (0, _container17.getContainersForNode)(childOfThird).pop();
|
|
181
|
-
expect(actual).toEqual(expected);
|
|
182
|
-
}));
|
|
183
|
-
});
|
|
184
|
-
describe('#isContainer', function () {
|
|
185
|
-
beforeEach(function () {
|
|
186
|
-
(0, _container17.configureContainer)('test-container');
|
|
187
|
-
});
|
|
188
|
-
afterEach(function () {
|
|
189
|
-
(0, _container17.removeContainer)('test-container');
|
|
190
|
-
});
|
|
191
|
-
test('should return true for nodes that have the container attribute', function () {
|
|
192
|
-
var div = document.createElement('div');
|
|
193
|
-
div.setAttribute('data-spotlight-container', 'my-container');
|
|
194
|
-
var expected = true;
|
|
195
|
-
var actual = (0, _container17.isContainer)(div);
|
|
196
|
-
expect(actual).toBe(expected);
|
|
197
|
-
});
|
|
198
|
-
test('should return false for nodes that do not have the container attribute', function () {
|
|
199
|
-
var div = document.createElement('div');
|
|
200
|
-
var expected = false;
|
|
201
|
-
var actual = (0, _container17.isContainer)(div);
|
|
202
|
-
expect(actual).toBe(expected);
|
|
203
|
-
});
|
|
204
|
-
test('should return true for a configured container id', function () {
|
|
205
|
-
var expected = true;
|
|
206
|
-
var actual = (0, _container17.isContainer)('test-container');
|
|
207
|
-
expect(actual).toBe(expected);
|
|
208
|
-
});
|
|
209
|
-
test('should return false for a unconfigured container id', function () {
|
|
210
|
-
var expected = false;
|
|
211
|
-
var actual = (0, _container17.isContainer)('unconfigured-container');
|
|
212
|
-
expect(actual).toBe(expected);
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
describe('#getContainerFocusTarget', function () {
|
|
216
|
-
beforeEach(setupContainers);
|
|
217
|
-
afterEach(teardownContainers);
|
|
218
|
-
test('should return the last focused element when enterTo is "last-focused"', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function (root) {
|
|
219
|
-
(0, _container17.configureContainer)('container', {
|
|
220
|
-
enterTo: 'last-focused',
|
|
221
|
-
defaultElement: '.spottable-default'
|
|
222
|
-
});
|
|
223
|
-
(0, _container17.setContainerLastFocusedElement)(root.querySelector('#lastFocused'), ['container']);
|
|
224
|
-
var expected = 'lastFocused';
|
|
225
|
-
var actual = (0, _container17.getContainerFocusTarget)('container').id;
|
|
226
|
-
expect(actual).toBe(expected);
|
|
227
|
-
}));
|
|
228
|
-
test('should return the default spottable element when enterTo is "last-focused" but no element has been focused', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
|
|
229
|
-
(0, _container17.configureContainer)('container', {
|
|
230
|
-
enterTo: 'last-focused',
|
|
231
|
-
defaultElement: '.spottable-default'
|
|
232
|
-
});
|
|
233
|
-
var expected = 'spottableDefault';
|
|
234
|
-
var actual = (0, _container17.getContainerFocusTarget)('container').id;
|
|
235
|
-
expect(actual).toBe(expected);
|
|
236
|
-
}));
|
|
237
|
-
test('should return the first spottable element when enterTo is "last-focused" and defaultElement is not configured', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
|
|
238
|
-
(0, _container17.configureContainer)('container', {
|
|
239
|
-
enterTo: 'last-focused'
|
|
240
|
-
});
|
|
241
|
-
var expected = 'firstSpottable';
|
|
242
|
-
var actual = (0, _container17.getContainerFocusTarget)('container').id;
|
|
243
|
-
expect(actual).toBe(expected);
|
|
244
|
-
}));
|
|
245
|
-
test('should return the first spottable element when enterTo is "last-focused" and defaultElement is not found', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
|
|
246
|
-
(0, _container17.configureContainer)('container', {
|
|
247
|
-
enterTo: 'last-focused',
|
|
248
|
-
// configured, but not found
|
|
249
|
-
defaultElement: '[data-default-spottable]'
|
|
250
|
-
});
|
|
251
|
-
var expected = 'firstSpottable';
|
|
252
|
-
var actual = (0, _container17.getContainerFocusTarget)('container').id;
|
|
253
|
-
expect(actual).toBe(expected);
|
|
254
|
-
}));
|
|
255
|
-
test('should return the default spottable element when enterTo is "default-element"', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
|
|
256
|
-
(0, _container17.configureContainer)('container', {
|
|
257
|
-
enterTo: 'default-element',
|
|
258
|
-
defaultElement: '.spottable-default'
|
|
259
|
-
});
|
|
260
|
-
var expected = 'spottableDefault';
|
|
261
|
-
var actual = (0, _container17.getContainerFocusTarget)('container').id;
|
|
262
|
-
expect(actual).toBe(expected);
|
|
263
|
-
}));
|
|
264
|
-
test('should return the default spottable element when enterTo is "default-element" and defaultElement contains an array of selectors', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
|
|
265
|
-
(0, _container17.configureContainer)('container', {
|
|
266
|
-
enterTo: 'default-element',
|
|
267
|
-
defaultElement: ['.does-not-exist', '.spottable-default']
|
|
268
|
-
});
|
|
269
|
-
var expected = 'spottableDefault';
|
|
270
|
-
var actual = (0, _container17.getContainerFocusTarget)('container').id;
|
|
271
|
-
expect(actual).toBe(expected);
|
|
272
|
-
})); // FIXME: This is testing a previously supported feature (setting a node as defaultElement)
|
|
273
|
-
// which was never documented and should be removed in a future release.
|
|
274
|
-
|
|
275
|
-
test('should return the default spottable element when enterTo is "default-element" and defaultElement contains an array of selectors wiht a node reference', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function (root) {
|
|
276
|
-
(0, _container17.configureContainer)('container', {
|
|
277
|
-
enterTo: 'default-element',
|
|
278
|
-
defaultElement: [root.querySelector('#lastFocused'), '.spottable-default']
|
|
279
|
-
});
|
|
280
|
-
var expected = 'lastFocused';
|
|
281
|
-
var actual = (0, _container17.getContainerFocusTarget)('container').id;
|
|
282
|
-
expect(actual).toBe(expected);
|
|
283
|
-
}));
|
|
284
|
-
test('should return the first spottable element when enterTo is "default-element" but defaultElement is not configured', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
|
|
285
|
-
(0, _container17.configureContainer)('container', {
|
|
286
|
-
enterTo: 'default-element'
|
|
287
|
-
});
|
|
288
|
-
var expected = 'firstSpottable';
|
|
289
|
-
var actual = (0, _container17.getContainerFocusTarget)('container').id;
|
|
290
|
-
expect(actual).toBe(expected);
|
|
291
|
-
}));
|
|
292
|
-
test('should return the first spottable element when enterTo is "default-element" but defaultElement is not found', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
|
|
293
|
-
(0, _container17.configureContainer)('container', {
|
|
294
|
-
enterTo: 'default-element',
|
|
295
|
-
defaultElement: '[data-default-spottable]'
|
|
296
|
-
});
|
|
297
|
-
var expected = 'firstSpottable';
|
|
298
|
-
var actual = (0, _container17.getContainerFocusTarget)('container').id;
|
|
299
|
-
expect(actual).toBe(expected);
|
|
300
|
-
}));
|
|
301
|
-
test('should return the default element when enterTo is "default-element" and defaultElement is within a subcontainer', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
302
|
-
(0, _container17.configureContainer)('first-container', {
|
|
303
|
-
enterTo: 'default-element',
|
|
304
|
-
defaultElement: "[".concat(_container17.containerAttribute, "='second-container'] > .spottable")
|
|
305
|
-
});
|
|
306
|
-
(0, _container17.configureContainer)('second-container');
|
|
307
|
-
var expected = 'second-container';
|
|
308
|
-
var actual = (0, _container17.getContainerFocusTarget)('first-container').parentNode.dataset.spotlightId;
|
|
309
|
-
expect(actual).toBe(expected);
|
|
310
|
-
}));
|
|
311
|
-
test('should return the first spottable element when enterTo is "default-element" and defaultElement is within a disabled subcontainer', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
312
|
-
(0, _container17.configureContainer)('second-container', {
|
|
313
|
-
enterTo: 'default-element',
|
|
314
|
-
defaultElement: "[".concat(_container17.containerAttribute, "='third-container'] > .spottable")
|
|
315
|
-
});
|
|
316
|
-
(0, _container17.configureContainer)('third-container');
|
|
317
|
-
var expected = 'secondContainerFirstSpottable';
|
|
318
|
-
var actual = (0, _container17.getContainerFocusTarget)('second-container').id;
|
|
319
|
-
expect(actual).toBe(expected);
|
|
320
|
-
}));
|
|
321
|
-
test('should return the first spottable element when enterTo is not configured', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
|
|
322
|
-
(0, _container17.configureContainer)('container');
|
|
323
|
-
var expected = 'firstSpottable';
|
|
324
|
-
var actual = (0, _container17.getContainerFocusTarget)('container').id;
|
|
325
|
-
expect(actual).toBe(expected);
|
|
326
|
-
}));
|
|
327
|
-
test('should return the default element when enterTo is not configured and defaultElement is configured', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
|
|
328
|
-
(0, _container17.configureContainer)('container', {
|
|
329
|
-
defaultElement: '.spottable-default'
|
|
330
|
-
});
|
|
331
|
-
var expected = 'spottableDefault';
|
|
332
|
-
var actual = (0, _container17.getContainerFocusTarget)('container').id;
|
|
333
|
-
expect(actual).toBe(expected);
|
|
334
|
-
}));
|
|
335
|
-
test('should cascade search into child containers with', (0, _utils.testScenario)(scenarios.nestedContainersWithDefaultAndLastFocused, function (root) {
|
|
336
|
-
(0, _container17.configureContainer)('container', {
|
|
337
|
-
defaultElement: '.spottable-default'
|
|
338
|
-
});
|
|
339
|
-
(0, _container17.configureContainer)('child', {
|
|
340
|
-
enterTo: 'last-focused',
|
|
341
|
-
defaultElement: '.spottable-default'
|
|
342
|
-
});
|
|
343
|
-
(0, _container17.setContainerLastFocusedElement)(root.querySelector('#lastChildFocused'), [_container17.rootContainerId, 'container', 'child']);
|
|
344
|
-
var expected = 'lastChildFocused';
|
|
345
|
-
var actual = (0, _container17.getContainerFocusTarget)('container').id;
|
|
346
|
-
expect(actual).toBe(expected);
|
|
347
|
-
}));
|
|
348
|
-
test('should cascade search into child containers when multiple containers have enterTo configured', (0, _utils.testScenario)(scenarios.nestedContainersWithDefaultAndLastFocused, function (root) {
|
|
349
|
-
(0, _container17.configureContainer)('container', {
|
|
350
|
-
enterTo: 'last-focused',
|
|
351
|
-
defaultElement: '.spottable-default'
|
|
352
|
-
});
|
|
353
|
-
(0, _container17.configureContainer)('child', {
|
|
354
|
-
enterTo: 'last-focused',
|
|
355
|
-
defaultElement: '.spottable-default'
|
|
356
|
-
});
|
|
357
|
-
(0, _container17.setContainerLastFocusedElement)(root.querySelector('#lastChildFocused'), [_container17.rootContainerId, 'container', 'child']);
|
|
358
|
-
var expected = 'lastChildFocused';
|
|
359
|
-
var actual = (0, _container17.getContainerFocusTarget)('container').id;
|
|
360
|
-
expect(actual).toBe(expected);
|
|
361
|
-
}));
|
|
362
|
-
test('should skip empty subcontainers', (0, _utils.testScenario)(scenarios.emptySubcontainer, function () {
|
|
363
|
-
(0, _container17.configureContainer)('container');
|
|
364
|
-
(0, _container17.configureContainer)('subcontainer');
|
|
365
|
-
var expected = 'afterSubcontainer';
|
|
366
|
-
var actual = (0, _container17.getContainerFocusTarget)('container').id;
|
|
367
|
-
expect(actual).toBe(expected);
|
|
368
|
-
}));
|
|
369
|
-
test('should return null for an unconfigured container', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
370
|
-
var expected = null;
|
|
371
|
-
var actual = (0, _container17.getContainerFocusTarget)('first-container');
|
|
372
|
-
expect(actual).toBe(expected);
|
|
373
|
-
}));
|
|
374
|
-
});
|
|
375
|
-
describe('#isNavigable', function () {
|
|
376
|
-
beforeEach(setupContainers);
|
|
377
|
-
afterEach(teardownContainers);
|
|
378
|
-
test('should return false a null node', function () {
|
|
379
|
-
var expected = false;
|
|
380
|
-
var actual = (0, _container17.isNavigable)(null, _container17.rootContainerId);
|
|
381
|
-
expect(actual).toBe(expected);
|
|
382
|
-
});
|
|
383
|
-
test('should return true for any node when not verifying selector and without a navigableFilter', (0, _utils.testScenario)(scenarios.nonSpottableSiblings, function (root) {
|
|
384
|
-
var expected = true;
|
|
385
|
-
var actual = (0, _container17.isNavigable)(root.querySelector('.other'), _container17.rootContainerId);
|
|
386
|
-
expect(actual).toBe(expected);
|
|
387
|
-
}));
|
|
388
|
-
test('should return true for spottable children when verifying selector', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
|
|
389
|
-
var expected = true;
|
|
390
|
-
var actual = (0, _container17.isNavigable)(root.querySelector('.spottable'), _container17.rootContainerId, true);
|
|
391
|
-
expect(actual).toBe(expected);
|
|
392
|
-
}));
|
|
393
|
-
test('should return true for containers', (0, _utils.testScenario)(scenarios.onlyContainers, function (root) {
|
|
394
|
-
var expected = true;
|
|
395
|
-
var actual = (0, _container17.isNavigable)(root.querySelector("[".concat(_container17.containerAttribute, "]")), _container17.rootContainerId, true);
|
|
396
|
-
expect(actual).toBe(expected);
|
|
397
|
-
}));
|
|
398
|
-
test('should filter the node with navigableFilter', (0, _utils.testScenario)(scenarios.spottableAndContainers, function (root) {
|
|
399
|
-
(0, _container17.configureContainer)(_container17.rootContainerId, {
|
|
400
|
-
// test filter which makes containers non-navigable
|
|
401
|
-
navigableFilter: function navigableFilter(n) {
|
|
402
|
-
return !(0, _container17.isContainer)(n);
|
|
403
|
-
}
|
|
404
|
-
});
|
|
405
|
-
var expected = false;
|
|
406
|
-
var actual = (0, _container17.isNavigable)(root.querySelector("[".concat(_container17.containerAttribute, "]")), _container17.rootContainerId, true);
|
|
407
|
-
expect(actual).toBe(expected);
|
|
408
|
-
}));
|
|
409
|
-
});
|
|
410
|
-
describe('#setContainerLastFocusedElement', function () {
|
|
411
|
-
beforeEach(setupContainers);
|
|
412
|
-
afterEach(teardownContainers);
|
|
413
|
-
test('should update lastFocusedElement for a single container', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
|
|
414
|
-
var item = root.querySelectorAll('.spottable').item(3);
|
|
415
|
-
(0, _container17.setContainerLastFocusedElement)(item, (0, _container17.getContainersForNode)(item));
|
|
416
|
-
var expected = item;
|
|
417
|
-
var actual = (0, _container17.getContainerConfig)(_container17.rootContainerId).lastFocusedElement;
|
|
418
|
-
expect(actual).toBe(expected);
|
|
419
|
-
}));
|
|
420
|
-
test('should update lastFocusedElement to the node\'s container id when element is within a container with enterTo configured', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
421
|
-
var item = root.querySelectorAll("[".concat(_container17.containerAttribute, "='first-container'] .spottable")).item(0);
|
|
422
|
-
(0, _container17.configureContainer)('first-container', {
|
|
423
|
-
enterTo: 'last-focused'
|
|
424
|
-
});
|
|
425
|
-
(0, _container17.setContainerLastFocusedElement)(item, (0, _container17.getContainersForNode)(item));
|
|
426
|
-
var expected = 'first-container';
|
|
427
|
-
var actual = (0, _container17.getContainerConfig)(_container17.rootContainerId).lastFocusedElement;
|
|
428
|
-
expect(actual).toBe(expected);
|
|
429
|
-
}));
|
|
430
|
-
test('should ignore sub-containers that does not have enterTo configured', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
431
|
-
var item = root.querySelectorAll("[".concat(_container17.containerAttribute, "='second-container'] .spottable")).item(0);
|
|
432
|
-
(0, _container17.setContainerLastFocusedElement)(item, (0, _container17.getContainersForNode)(item));
|
|
433
|
-
var expected = item;
|
|
434
|
-
var actual = (0, _container17.getContainerConfig)(_container17.rootContainerId).lastFocusedElement;
|
|
435
|
-
expect(actual).toBe(expected);
|
|
436
|
-
}));
|
|
437
|
-
test('should update lastFocusedElement to the first sub-container that has enterTo configured', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
438
|
-
var item = root.querySelectorAll("[".concat(_container17.containerAttribute, "='second-container'] .spottable")).item(0);
|
|
439
|
-
(0, _container17.configureContainer)('second-container', {
|
|
440
|
-
enterTo: 'last-focused'
|
|
441
|
-
});
|
|
442
|
-
(0, _container17.setContainerLastFocusedElement)(item, (0, _container17.getContainersForNode)(item));
|
|
443
|
-
var expected = 'second-container';
|
|
444
|
-
var actual = (0, _container17.getContainerConfig)(_container17.rootContainerId).lastFocusedElement;
|
|
445
|
-
expect(actual).toBe(expected);
|
|
446
|
-
}));
|
|
447
|
-
});
|
|
448
|
-
describe('#unmountContainer', function () {
|
|
449
|
-
beforeEach(setupContainers);
|
|
450
|
-
afterEach(teardownContainers);
|
|
451
|
-
test('should return element when last focused is not within a subcontainer with enterTo', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
|
|
452
|
-
var index = 3;
|
|
453
|
-
var item = root.querySelectorAll('.spottable').item(index);
|
|
454
|
-
(0, _container17.setContainerLastFocusedElement)(item, (0, _container17.getContainersForNode)(item));
|
|
455
|
-
(0, _container17.unmountContainer)(_container17.rootContainerId);
|
|
456
|
-
var expected = true;
|
|
457
|
-
var actual = (0, _container17.getContainerConfig)(_container17.rootContainerId).lastFocusedKey.element;
|
|
458
|
-
expect(actual).toBe(expected);
|
|
459
|
-
}));
|
|
460
|
-
test('should return container when last focused is within a subcontainer with enterTo', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
461
|
-
var item = root.querySelectorAll("[".concat(_container17.containerAttribute, "=\"first-container\"] .spottable")).item(1);
|
|
462
|
-
(0, _container17.configureContainer)('first-container', {
|
|
463
|
-
enterTo: 'last-focused'
|
|
464
|
-
});
|
|
465
|
-
(0, _container17.setContainerLastFocusedElement)(item, (0, _container17.getContainersForNode)(item));
|
|
466
|
-
(0, _container17.unmountContainer)(_container17.rootContainerId);
|
|
467
|
-
var expected = true;
|
|
468
|
-
var actual = (0, _container17.getContainerConfig)(_container17.rootContainerId).lastFocusedKey.container;
|
|
469
|
-
expect(actual).toBe(expected);
|
|
470
|
-
}));
|
|
471
|
-
test('should save the index of the node when lastFocusedPersist is undefined', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
|
|
472
|
-
var index = 3;
|
|
473
|
-
var item = root.querySelectorAll('.spottable').item(index);
|
|
474
|
-
(0, _container17.setContainerLastFocusedElement)(item, (0, _container17.getContainersForNode)(item));
|
|
475
|
-
(0, _container17.unmountContainer)(_container17.rootContainerId);
|
|
476
|
-
var expected = index;
|
|
477
|
-
var actual = (0, _container17.getContainerConfig)(_container17.rootContainerId).lastFocusedKey.key;
|
|
478
|
-
expect(actual).toBe(expected);
|
|
479
|
-
}));
|
|
480
|
-
test('should save a custom key for container-configured lastFocusedPersist', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
|
|
481
|
-
var index = 3;
|
|
482
|
-
var item = root.querySelectorAll('.spottable').item(3);
|
|
483
|
-
(0, _container17.configureContainer)(_container17.rootContainerId, {
|
|
484
|
-
lastFocusedPersist: function lastFocusedPersist(n, all) {
|
|
485
|
-
return {
|
|
486
|
-
element: true,
|
|
487
|
-
key: "item-".concat(all.indexOf(n))
|
|
488
|
-
};
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
(0, _container17.setContainerLastFocusedElement)(item, (0, _container17.getContainersForNode)(item));
|
|
492
|
-
(0, _container17.unmountContainer)(_container17.rootContainerId);
|
|
493
|
-
var expected = "item-".concat(index);
|
|
494
|
-
var actual = (0, _container17.getContainerConfig)(_container17.rootContainerId).lastFocusedKey.key;
|
|
495
|
-
expect(actual).toBe(expected);
|
|
496
|
-
}));
|
|
497
|
-
test('should save the container id as the key when a container with enterTo configured had the last focused item', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
498
|
-
var item = root.querySelectorAll("[".concat(_container17.containerAttribute, "=\"first-container\"] .spottable")).item(1);
|
|
499
|
-
(0, _container17.configureContainer)('first-container', {
|
|
500
|
-
enterTo: 'last-focused'
|
|
501
|
-
});
|
|
502
|
-
(0, _container17.setContainerLastFocusedElement)(item, (0, _container17.getContainersForNode)(item));
|
|
503
|
-
(0, _container17.unmountContainer)(_container17.rootContainerId);
|
|
504
|
-
var expected = 'first-container';
|
|
505
|
-
var actual = (0, _container17.getContainerConfig)(_container17.rootContainerId).lastFocusedKey.key;
|
|
506
|
-
expect(actual).toBe(expected);
|
|
507
|
-
}));
|
|
508
|
-
test('should save the index as the key when last focused item is only within containers without enterTo configured', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
509
|
-
var item = root.querySelectorAll("[".concat(_container17.containerAttribute, "=\"second-container\"] .spottable")).item(1);
|
|
510
|
-
(0, _container17.setContainerLastFocusedElement)(item, (0, _container17.getContainersForNode)(item));
|
|
511
|
-
(0, _container17.unmountContainer)(_container17.rootContainerId);
|
|
512
|
-
var expected = 4;
|
|
513
|
-
var actual = (0, _container17.getContainerConfig)(_container17.rootContainerId).lastFocusedKey.key;
|
|
514
|
-
expect(actual).toBe(expected);
|
|
515
|
-
}));
|
|
516
|
-
test('should mark the container inactive', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
517
|
-
(0, _container17.addContainer)('first-container');
|
|
518
|
-
(0, _container17.unmountContainer)('first-container');
|
|
519
|
-
var expected = false;
|
|
520
|
-
var actual = (0, _container17.getContainerConfig)('first-container').active;
|
|
521
|
-
expect(actual).toBe(expected);
|
|
522
|
-
}));
|
|
523
|
-
});
|
|
524
|
-
describe('#setLastContainerFromTarget', function () {
|
|
525
|
-
beforeEach(setupContainers);
|
|
526
|
-
afterEach(teardownContainers);
|
|
527
|
-
test('should be nearest restrict="self-only" container to current if target is not within it', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
528
|
-
(0, _container17.configureContainer)('first-container', {
|
|
529
|
-
restrict: 'self-only'
|
|
530
|
-
});
|
|
531
|
-
var current = root.querySelector('[data-spotlight-id="first-container"] .spottable');
|
|
532
|
-
var target = root.querySelector('.spottable');
|
|
533
|
-
(0, _container17.setLastContainerFromTarget)(current, target);
|
|
534
|
-
var expected = 'first-container';
|
|
535
|
-
var actual = (0, _container17.getLastContainer)();
|
|
536
|
-
expect(actual).toBe(expected);
|
|
537
|
-
}));
|
|
538
|
-
test('should be use nearest container to target if within current container', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
539
|
-
(0, _container17.configureContainer)('first-container', {
|
|
540
|
-
restrict: 'none'
|
|
541
|
-
});
|
|
542
|
-
(0, _container17.configureContainer)('second-container', {
|
|
543
|
-
restrict: 'none'
|
|
544
|
-
});
|
|
545
|
-
var current = root.querySelector('[data-spotlight-id="first-container"] .spottable');
|
|
546
|
-
var target = root.querySelector('[data-spotlight-id="second-container"] .spottable');
|
|
547
|
-
(0, _container17.setLastContainerFromTarget)(current, target);
|
|
548
|
-
var expected = 'second-container';
|
|
549
|
-
var actual = (0, _container17.getLastContainer)();
|
|
550
|
-
expect(actual).toBe(expected);
|
|
551
|
-
}));
|
|
552
|
-
test('should target container if it is restrict="self-only" and contains current container', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
553
|
-
(0, _container17.configureContainer)('first-container', {
|
|
554
|
-
restrict: 'self-only'
|
|
555
|
-
});
|
|
556
|
-
(0, _container17.configureContainer)('second-container', {
|
|
557
|
-
restrict: 'none'
|
|
558
|
-
});
|
|
559
|
-
var current = root.querySelector('[data-spotlight-id="second-container"] .spottable');
|
|
560
|
-
var target = root.querySelector('[data-spotlight-id="first-container"]');
|
|
561
|
-
(0, _container17.setLastContainerFromTarget)(current, target);
|
|
562
|
-
var expected = 'first-container';
|
|
563
|
-
var actual = (0, _container17.getLastContainer)();
|
|
564
|
-
expect(actual).toBe(expected);
|
|
565
|
-
}));
|
|
566
|
-
});
|
|
567
|
-
describe('#getDefaultContainer', function () {
|
|
568
|
-
beforeEach(setupContainers);
|
|
569
|
-
afterEach(teardownContainers);
|
|
570
|
-
test('should return an empty string when container is inactive', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
571
|
-
(0, _container17.unmountContainer)(_container17.rootContainerId);
|
|
572
|
-
var expected = '';
|
|
573
|
-
var actual = (0, _container17.getDefaultContainer)();
|
|
574
|
-
expect(actual).toBe(expected);
|
|
575
|
-
}));
|
|
576
|
-
});
|
|
577
|
-
describe('#getLastContainer', function () {
|
|
578
|
-
beforeEach(setupContainers);
|
|
579
|
-
afterEach(teardownContainers);
|
|
580
|
-
test('should return an empty string when container is inactive', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
581
|
-
(0, _container17.addContainer)('first-container');
|
|
582
|
-
(0, _container17.setLastContainer)('first-container');
|
|
583
|
-
(0, _container17.unmountContainer)('first-container');
|
|
584
|
-
var expected = '';
|
|
585
|
-
var actual = (0, _container17.getLastContainer)();
|
|
586
|
-
expect(actual).toBe(expected);
|
|
587
|
-
}));
|
|
588
|
-
});
|
|
589
|
-
describe('#getAllContainerIds', function () {
|
|
590
|
-
beforeEach(setupContainers);
|
|
591
|
-
afterEach(teardownContainers);
|
|
592
|
-
test('should not include inacive containers', (0, _utils.testScenario)(scenarios.onlyContainers, function (root) {
|
|
593
|
-
var containerId = root.querySelector('[data-spotlight-id]').dataset.containerId;
|
|
594
|
-
(0, _container17.addContainer)(containerId);
|
|
595
|
-
(0, _container17.unmountContainer)(containerId);
|
|
596
|
-
var expected = -1;
|
|
597
|
-
var actual = (0, _container17.getAllContainerIds)().indexOf(containerId);
|
|
598
|
-
expect(actual).toBe(expected);
|
|
599
|
-
}));
|
|
600
|
-
});
|
|
601
|
-
describe('#getContainerLastFocusedElement', function () {
|
|
602
|
-
beforeEach(setupContainers);
|
|
603
|
-
afterEach(teardownContainers);
|
|
604
|
-
test('should return null for an invalid container', (0, _utils.testScenario)(scenarios.onlySpottables, function () {
|
|
605
|
-
var expected = null;
|
|
606
|
-
var actual = (0, _container17.getContainerLastFocusedElement)('does-not-exist');
|
|
607
|
-
expect(actual).toBe(expected);
|
|
608
|
-
}));
|
|
609
|
-
});
|
|
610
|
-
describe('#getContainerDefaultElement', function () {
|
|
611
|
-
beforeEach(setupContainers);
|
|
612
|
-
afterEach(teardownContainers);
|
|
613
|
-
test('should return null for an invalid container', (0, _utils.testScenario)(scenarios.onlySpottables, function () {
|
|
614
|
-
var expected = null;
|
|
615
|
-
var actual = (0, _container17.getContainerDefaultElement)('does-not-exist');
|
|
616
|
-
expect(actual).toBe(expected);
|
|
617
|
-
}));
|
|
618
|
-
});
|
|
619
|
-
describe('#getNavigableContainersForNode', function () {
|
|
620
|
-
beforeEach(setupContainers);
|
|
621
|
-
afterEach(teardownContainers);
|
|
622
|
-
test('should include all containers when none are restrict="self-only"', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
623
|
-
var expected = [_container17.rootContainerId, 'first-container', 'second-container'];
|
|
624
|
-
var actual = (0, _container17.getNavigableContainersForNode)(root.querySelector('#secondContainerFirstSpottable'));
|
|
625
|
-
expect(actual).toEqual(expected);
|
|
626
|
-
}));
|
|
627
|
-
test('should include all containers within the first restrict="self-only" container (inclusive)', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
628
|
-
(0, _container17.configureContainer)('first-container', {
|
|
629
|
-
restrict: 'self-only'
|
|
630
|
-
});
|
|
631
|
-
var expected = ['first-container', 'second-container'];
|
|
632
|
-
var actual = (0, _container17.getNavigableContainersForNode)(root.querySelector('#secondContainerFirstSpottable'));
|
|
633
|
-
expect(actual).toEqual(expected);
|
|
634
|
-
}));
|
|
635
|
-
});
|
|
636
|
-
describe('#getContainerNavigableElements', function () {
|
|
637
|
-
beforeEach(setupContainers);
|
|
638
|
-
afterEach(teardownContainers);
|
|
639
|
-
test('should return an empty array for an unconfigured container', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
640
|
-
var expected = [];
|
|
641
|
-
var actual = (0, _container17.getContainerNavigableElements)('first-container');
|
|
642
|
-
expect(actual).toEqual(expected);
|
|
643
|
-
}));
|
|
644
|
-
test('should return an empty array for an unmounted, configured container', (0, _utils.testScenario)(scenarios.onlySpottables, function () {
|
|
645
|
-
(0, _container17.configureContainer)('first-container', {
|
|
646
|
-
overflow: true
|
|
647
|
-
});
|
|
648
|
-
var expected = [];
|
|
649
|
-
var actual = (0, _container17.getContainerNavigableElements)('first-container');
|
|
650
|
-
expect(actual).toEqual(expected);
|
|
651
|
-
}));
|
|
652
|
-
});
|
|
653
|
-
});
|