2020-09-30 21:10:09 +00:00
import { merge } from 'lodash' ;
export function withGonExperiment ( experimentKey , value = true ) {
let origGon ;
beforeEach ( ( ) => {
origGon = window . gon ;
window . gon = merge ( { } , window . gon || { } , { experiments : { [ experimentKey ] : value } } ) ;
} ) ;
afterEach ( ( ) => {
window . gon = origGon ;
} ) ;
}
2021-04-02 18:09:20 +00:00
// This helper is for specs that use `gitlab-experiment` utilities, which have a different schema that gets pushed via Gon compared to `Experimentation Module`
export function assignGitlabExperiment ( experimentKey , variant ) {
let origGon ;
beforeEach ( ( ) => {
origGon = window . gon ;
window . gon = { experiment : { [ experimentKey ] : { variant } } } ;
} ) ;
afterEach ( ( ) => {
window . gon = origGon ;
} ) ;
}