2021-01-03 14:25:43 +05:30
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-29 21:17:54 +05:30
// 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 ;
} ) ;
}