Skip to content

Commit

Permalink
test: add tests to verify setting cookie domain option works correctly (
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpagtakhan committed Aug 24, 2023
1 parent 5e4a409 commit b85521e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/analytics-browser/test/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ describe('config', () => {

describe('useBrowserConfig', () => {
test('should create default config', async () => {
const getTopLevelDomain = jest.spyOn(Config, 'getTopLevelDomain').mockResolvedValueOnce('.amplitude.com');
const logger = new core.Logger();
logger.enable(LogLevel.Warn);
const config = await Config.useBrowserConfig(apiKey, undefined, new AmplitudeBrowser());
Expand All @@ -98,7 +99,7 @@ describe('config', () => {
apiKey,
appVersion: undefined,
cookieOptions: {
domain: '',
domain: '.amplitude.com',
expiration: 365,
sameSite: 'Lax',
secure: false,
Expand Down Expand Up @@ -128,6 +129,7 @@ describe('config', () => {
transportProvider: new FetchTransport(),
useBatch: false,
});
expect(getTopLevelDomain).toHaveBeenCalledTimes(1);
});

test('should create using cookies/overwrite', async () => {
Expand Down Expand Up @@ -159,6 +161,7 @@ describe('config', () => {
},
sessionTimeout: 1,
cookieOptions: {
domain: '.amplitude.com',
upgrade: false,
},
},
Expand All @@ -175,7 +178,7 @@ describe('config', () => {
apiKey,
appVersion: undefined,
cookieOptions: {
domain: '',
domain: '.amplitude.com',
expiration: 365,
sameSite: 'Lax',
secure: false,
Expand Down

0 comments on commit b85521e

Please sign in to comment.