From 32ef44e54148842c62630a237bfbf7bc3da6f90c Mon Sep 17 00:00:00 2001 From: Jack Ord Date: Wed, 27 Sep 2023 15:55:08 +0000 Subject: [PATCH] Test selectIsConstraintActive selector --- .../experiment/experiment-selectors.test.ts | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/core/src/context/experiment/experiment-selectors.test.ts b/packages/core/src/context/experiment/experiment-selectors.test.ts index 93809b5d..0fcf5179 100644 --- a/packages/core/src/context/experiment/experiment-selectors.test.ts +++ b/packages/core/src/context/experiment/experiment-selectors.test.ts @@ -1,8 +1,8 @@ import { initialState, State } from '@core/context/experiment/store' import { selectCalculatedSuggestionCount, - selectCalculatedSuggestionCountFromExperiment, selectId, + selectIsConstraintActive, selectIsInitializing, selectIsMultiObjective, selectIsSuggestionCountEditable, @@ -151,4 +151,28 @@ describe('Experiment selectors', () => { } ) }) + + describe('selectIsConstraintActive', () => { + it.each([ + [['a', 'b', 'c'], true], + [['a', 'b'], true], + [['a'], false], + [[], false], + ])( + 'should return true when number of sum constraint variables > 1', + (dimensions, result) => { + const editable = selectIsConstraintActive({ + ...initialState.experiment, + constraints: [ + { + type: 'sum', + value: 100, + dimensions, + }, + ], + }) + expect(editable).toBe(result) + } + ) + }) })