Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/experimentation/utils_spec.js')
-rw-r--r--spec/frontend/experimentation/utils_spec.js49
1 files changed, 30 insertions, 19 deletions
diff --git a/spec/frontend/experimentation/utils_spec.js b/spec/frontend/experimentation/utils_spec.js
index 923795ca3f3..0d663fd055e 100644
--- a/spec/frontend/experimentation/utils_spec.js
+++ b/spec/frontend/experimentation/utils_spec.js
@@ -51,6 +51,29 @@ describe('experiment Utilities', () => {
expect(experimentUtils.getExperimentData(...input)).toEqual(output);
});
});
+
+ it('only collects the data properties which are supported by the schema', () => {
+ origGl = window.gl;
+ window.gl.experiments = {
+ my_experiment: {
+ experiment: 'my_experiment',
+ variant: 'control',
+ key: 'randomization-unit-key',
+ migration_keys: 'migration_keys object',
+ excluded: false,
+ other: 'foobar',
+ },
+ };
+
+ expect(experimentUtils.getExperimentData('my_experiment')).toEqual({
+ experiment: 'my_experiment',
+ variant: 'control',
+ key: 'randomization-unit-key',
+ migration_keys: 'migration_keys object',
+ });
+
+ window.gl = origGl;
+ });
});
describe('getAllExperimentContexts', () => {
@@ -72,29 +95,17 @@ describe('experiment Utilities', () => {
it('returns an empty array if there are no experiments', () => {
expect(experimentUtils.getAllExperimentContexts()).toEqual([]);
});
-
- it('only collects the data properties which are supported by the schema', () => {
- origGl = window.gl;
- window.gl.experiments = {
- my_experiment: { experiment: 'my_experiment', variant: 'control', excluded: false },
- };
-
- expect(experimentUtils.getAllExperimentContexts()).toEqual([
- { schema, data: { experiment: 'my_experiment', variant: 'control' } },
- ]);
-
- window.gl = origGl;
- });
});
describe('isExperimentVariant', () => {
describe.each`
- experiment | variant | input | output
- ${ABC_KEY} | ${DEFAULT_VARIANT} | ${[ABC_KEY, DEFAULT_VARIANT]} | ${true}
- ${ABC_KEY} | ${'_variant_name'} | ${[ABC_KEY, '_variant_name']} | ${true}
- ${ABC_KEY} | ${'_variant_name'} | ${[ABC_KEY, '_bogus_name']} | ${false}
- ${ABC_KEY} | ${'_variant_name'} | ${['boguskey', '_variant_name']} | ${false}
- ${undefined} | ${undefined} | ${[ABC_KEY, '_variant_name']} | ${false}
+ experiment | variant | input | output
+ ${ABC_KEY} | ${CANDIDATE_VARIANT} | ${[ABC_KEY]} | ${true}
+ ${ABC_KEY} | ${DEFAULT_VARIANT} | ${[ABC_KEY, DEFAULT_VARIANT]} | ${true}
+ ${ABC_KEY} | ${'_variant_name'} | ${[ABC_KEY, '_variant_name']} | ${true}
+ ${ABC_KEY} | ${'_variant_name'} | ${[ABC_KEY, '_bogus_name']} | ${false}
+ ${ABC_KEY} | ${'_variant_name'} | ${['boguskey', '_variant_name']} | ${false}
+ ${undefined} | ${undefined} | ${[ABC_KEY, '_variant_name']} | ${false}
`(
'with input=$input, experiment=$experiment, variant=$variant',
({ experiment, variant, input, output }) => {