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

Function test

test/unit/test-cookies.js:145–163  ·  view source on GitHub ↗
(url, targetDomain, opt_allowProxyOrigin)

Source from the content-addressed store, hash-verified

143
144 it('should write the cookie to the right domain on origin', () => {
145 function test(url, targetDomain, opt_allowProxyOrigin) {
146 expect(doc.cookie).to.equal('');
147 win.location = url;
148 setCookie(win, 'c&1', 'v&1', Date.now() + BASE_CID_MAX_AGE_MILLIS, {
149 highestAvailableDomain: true,
150 allowOnProxyOrigin: opt_allowProxyOrigin,
151 });
152 expect(doc.lastSetCookieRaw).to.equal(
153 `c%261=v%261; path=/; domain=${targetDomain}; ` +
154 'expires=Tue, 01 Jan 2019 08:00:00 GMT'
155 );
156 expect(doc.cookie).to.equal('c%261=v%261');
157 // Erase cookie
158 setCookie(win, 'c&1', 'v&1', Date.now() - 1000, {
159 highestAvailableDomain: true,
160 allowOnProxyOrigin: opt_allowProxyOrigin,
161 });
162 expect(doc.cookie).to.equal('');
163 }
164
165 //example.com
166 test('https://www.example.com/test.html', 'example.com');

Callers 1

test-cookies.jsFile · 0.70

Calls 3

setCookieFunction · 0.90
expectFunction · 0.85
nowMethod · 0.80

Tested by

no test coverage detected