From df042df49509f239d72c69bbd8df64e6996d6f3f Mon Sep 17 00:00:00 2001 From: Alessio Biancalana Date: Wed, 24 May 2023 12:11:20 +0200 Subject: [PATCH] fixup! Persist selected filters in checks results inside Redux --- .../clusterChecksResultsFilters.test.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 assets/js/state/selectors/clusterChecksResultsFilters.test.js diff --git a/assets/js/state/selectors/clusterChecksResultsFilters.test.js b/assets/js/state/selectors/clusterChecksResultsFilters.test.js new file mode 100644 index 0000000000..8a77caa9b1 --- /dev/null +++ b/assets/js/state/selectors/clusterChecksResultsFilters.test.js @@ -0,0 +1,23 @@ +import { faker } from '@faker-js/faker'; + +import { getSelectedFilters } from './clusterChecksResultsFilters'; + +describe('getSelectedFilters', () => { + it('should return an empty array if the cluster ID is not found', () => { + const clusterID = faker.datatype.uuid(); + expect( + getSelectedFilters(clusterID)({ clusterChecksResultsFilters: {} }) + ).toEqual([]); + }); + + it('should return a list of selected filters when the cluster ID is found', () => { + const clusterID = faker.datatype.uuid(); + const state = { + clusterChecksResultsFilters: { [clusterID]: ['passing', 'critical'] }, + }; + expect(getSelectedFilters(clusterID)(state)).toEqual([ + 'passing', + 'critical', + ]); + }); +});