Repository URL to install this package:
|
Version:
5.0.0-rc.5 ▾
|
import getCookieDomain from './getCookieDomain';
describe('getCookieDomain', () => {
beforeAll(() => {
delete window.location;
Object.defineProperty(window, 'location', { value: {} });
});
test('only top-level domains', async () => {
Object.defineProperty(window.location, 'hostname', { value: 'subdomain.topleveldomain.com', configurable: true });
expect(getCookieDomain()).toEqual('.topleveldomain.com');
Object.defineProperty(window.location, 'hostname', {
value: 'more.subdomain.topleveldomain.com',
configurable: true,
});
expect(getCookieDomain()).toEqual('.topleveldomain.com');
});
test('does not add dot in front of localhost', async () => {
Object.defineProperty(window.location, 'hostname', { value: 'localhost', configurable: true });
expect(getCookieDomain()).toEqual('localhost');
});
});