| 1 |
import { getAbTest } from '@auto-launch/functions/getAbTest'; |
| 2 |
|
| 3 |
afterEach(() => { |
| 4 |
window.extLaunchData = undefined; |
| 5 |
}); |
| 6 |
|
| 7 |
describe('getAbTest', () => { |
| 8 |
it('returns variant and percentage from the assignment-record shape', () => { |
| 9 |
window.extLaunchData = { |
| 10 |
activeTests: { |
| 11 |
'AutoLaunch.ShowTitle': { |
| 12 |
variant: 'B', |
| 13 |
percentage: 20, |
| 14 |
}, |
| 15 |
}, |
| 16 |
}; |
| 17 |
expect(getAbTest('AutoLaunch.ShowTitle')).toEqual({ |
| 18 |
variant: 'B', |
| 19 |
percentage: 20, |
| 20 |
}); |
| 21 |
}); |
| 22 |
|
| 23 |
it('returns nulls for an unassigned test key', () => { |
| 24 |
window.extLaunchData = { activeTests: {} }; |
| 25 |
expect(getAbTest('AutoLaunch.ShowTitle')).toEqual({ |
| 26 |
variant: null, |
| 27 |
percentage: null, |
| 28 |
}); |
| 29 |
}); |
| 30 |
}); |
| 31 |
|