From 21a6e227116f26981533224d9d6634fae221e291 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 16 Apr 2020 03:28:15 +0200 Subject: [PATCH] update unittests: add test for disabled choices getter --- src/scripts/choices.test.ts | 6 +++++- src/scripts/store/store.test.ts | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/scripts/choices.test.ts b/src/scripts/choices.test.ts index 20629fb..bdd7567 100644 --- a/src/scripts/choices.test.ts +++ b/src/scripts/choices.test.ts @@ -2176,6 +2176,7 @@ describe('choices', () => { describe('_onKeyDown', () => { let activeItems; + let disabledChoices; let hasItems; let hasActiveDropdown; let hasFocussedInput; @@ -2188,7 +2189,7 @@ describe('choices', () => { instance._onDirectionKey = stub(); instance._onDeleteKey = stub(); - ({ activeItems } = instance._store); + ({ activeItems, disabledChoices } = instance._store); hasItems = instance.itemList.hasChildren(); hasActiveDropdown = instance.dropdown.isActive; hasFocussedInput = instance.input.isFocussed; @@ -2212,6 +2213,8 @@ describe('choices', () => { expect(instance._onDirectionKey).to.have.been.calledWith( event, + activeItems, + disabledChoices, hasActiveDropdown, ); }); @@ -2244,6 +2247,7 @@ describe('choices', () => { expect(instance._onEnterKey).to.have.been.calledWith( event, activeItems, + disabledChoices, hasActiveDropdown, ); }); diff --git a/src/scripts/store/store.test.ts b/src/scripts/store/store.test.ts index e7be703..bfdb814 100644 --- a/src/scripts/store/store.test.ts +++ b/src/scripts/store/store.test.ts @@ -191,6 +191,15 @@ describe('reducers/store', () => { }); }); + describe('disabledChoices getter', () => { + it('returns choices that are disabled', () => { + const expectedResponse = state.choices.filter( + choice => choice.disabled, + ); + expect(instance.disabledChoices).to.eql(expectedResponse); + }); + }); + describe('selectableChoices getter', () => { it('returns choices that are not disabled', () => { const expectedResponse = state.choices.filter(