MCPcopy
hub / github.com/ampproject/amphtml / expectToggle

Function expectToggle

test/unit/test-experiments.js:238–252  ·  view source on GitHub ↗
(storedString, experimentId, opt_on)

Source from the content-addressed store, hash-verified

236 });
237
238 function expectToggle(storedString, experimentId, opt_on) {
239 resetExperimentTogglesForTesting(window);
240 const win = {
241 document: {},
242 localStorage: fakeLocalStorage({'amp-experiment-toggles': storedString}),
243 location: {
244 hostname: 'test.test',
245 href: 'https://test.test/test.html',
246 },
247 };
248 const on = toggleExperiment(win, experimentId, opt_on);
249 const newString = win.localStorage.getItem('amp-experiment-toggles');
250 // eslint-disable-next-line chai-expect/missing-assertion
251 return expect(`${on}; ${newString}`);
252 }
253
254 it('should toggle to "on" with no cookies, malformed or empty', () => {
255 expectToggle(null, 'e1').to.equal('true; e1');

Callers 1

Calls 5

fakeLocalStorageFunction · 0.85
toggleExperimentFunction · 0.85
expectFunction · 0.85
getItemMethod · 0.80

Tested by

no test coverage detected