Skip to content

Commit

Permalink
fix(spatial-navigation): add test for buttons of modal error
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosVillasenor committed Jul 26, 2024
1 parent dad4de8 commit 9bbcaf5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/js/spatial-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ class SpatialNavigation extends EventTarget {
// Add elements as objects to be handled by the spatial navigation
focusableComponents.push({
name: () => {
return 'ModalButton' + index + 1;
return 'ModalButton' + (index + 1);
},
el: () => element,
getPositions: () => {
Expand Down
4 changes: 4 additions & 0 deletions test/unit/spatial-navigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,4 +564,8 @@ QUnit.test('on error, modalButtons should get the buttons if those are available
assert.strictEqual(this.spatialNav.focusableComponents.length, 2, 'button elements are now part of the array of focusableComponents');
assert.ok(getPositionsEl1Spy.calledOnce, 'getPositions method called on button');
assert.ok(getPositionsEl2Spy.calledOnce, 'getPositions method called on button');
assert.strictEqual(this.spatialNav.focusableComponents[0].name(), 'ModalButton1', 'testEl1 name should be ModalButton1');
assert.strictEqual(this.spatialNav.focusableComponents[1].name(), 'ModalButton2', 'testEl2 name should be ModalButton2');
assert.strictEqual(this.spatialNav.focusableComponents[0].el() instanceof Element, true, 'el function from modal buttons should return a DOM element'); // eslint-disable-line no-undef
assert.strictEqual(this.spatialNav.focusableComponents[0].getIsFocusable(), true, 'getIsFocusable function from modal buttons is always true');
});

0 comments on commit 9bbcaf5

Please sign in to comment.