Skip to content

Commit

Permalink
fix(spatial-navigation): add test for array of 'focusableComponents'
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosVillasenor committed Jul 26, 2024
1 parent e3d0ae4 commit 84dbb11
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/unit/spatial-navigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,3 +591,24 @@ QUnit.test('on error, modalButtons added functions should work properly', functi
assert.strictEqual(this.spatialNav.focusableComponents[0].getIsAvailableToBeFocused(), true, 'getIsAvailableToBeFocused function from modal buttons is always true');
assert.strictEqual(typeof this.spatialNav.focusableComponents[0].getPositions(), 'object', 'focusableComponents function from modal buttons should return an object');
});

QUnit.test('If component passes the required functions it should be added to focusableComponents', function(assert) {
this.spatialNav.start();

const firstComponent = {
name_: 'firstComponent',
name: () => this.name,
el_: document.createElement('div'),
el: () => this.el_,
focus: sinon.spy(),
getIsAvailableToBeFocused: () => true,
getIsFocusable: () => true
};

this.player.children_.push(firstComponent);
this.spatialNav.getCurrentComponent = () => firstComponent;
this.spatialNav.updateFocusableComponents();

assert.strictEqual(this.spatialNav.focusableComponents.length, 1, 'focusableComponents array should have 1 component');
assert.strictEqual(this.spatialNav.focusableComponents[0].name_, 'firstComponent', 'the name of the component in focusableComponents array should be "firstComponent"');
});

0 comments on commit 84dbb11

Please sign in to comment.