Skip to content

Commit

Permalink
test: improve code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
saikumarrs committed Nov 8, 2024
1 parent c9be93a commit bd79c67
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const DeviceModeDestinations = (): ExtensionPlugin => ({
externalSrcLoader: IExternalSrcLoader,
errorHandler?: IErrorHandler,
logger?: ILogger,
externalScriptOnLoad?: (id?: string) => void,
externalScriptOnLoad?: (id?: string, error?: Error) => void,
) {
const integrationsCDNPath = state.lifecycle.integrationsCDNPath.value;
const activeDestinations = state.nativeDestinations.activeDestinations.value;
Expand Down
36 changes: 14 additions & 22 deletions packages/analytics-js/__fixtures__/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { SourceConfigResponse } from '@rudderstack/analytics-js/components/configManager/types';
import { COOKIE_KEYS } from '@rudderstack/analytics-js-cookies/constants/cookies';
import type { StorageEntries } from '@rudderstack/analytics-js-common/types/ApplicationState';
import type { SourceConfigResponse } from '@rudderstack/analytics-js-common/types/LoadOptions';

const identifyRequestPayload = {
userId: '123456',
Expand Down Expand Up @@ -42,15 +43,6 @@ const screenRequestPayload = {
},
};

const groupRequestPayload = {
userId: '12345',
groupId: '1',
traits: {
name: 'Company',
description: 'Google',
},
};

const aliasRequestPayload = {
previousId: 'old_id',
userId: 'new_id',
Expand Down Expand Up @@ -264,7 +256,7 @@ const entriesWithOnlyCookieStorage = {
type: 'cookieStorage',
key: COOKIE_KEYS.authToken,
},
};
} as unknown as StorageEntries;

const entriesWithOnlyLocalStorage = {
userId: {
Expand Down Expand Up @@ -303,7 +295,7 @@ const entriesWithOnlyLocalStorage = {
type: 'localStorage',
key: COOKIE_KEYS.authToken,
},
};
} as unknown as StorageEntries;

const entriesWithoutCookieStorage = {
userId: {
Expand Down Expand Up @@ -342,7 +334,7 @@ const entriesWithoutCookieStorage = {
type: 'localStorage',
key: COOKIE_KEYS.authToken,
},
};
} as unknown as StorageEntries;

const entriesWithoutCookieAndLocalStorage = {
userId: {
Expand Down Expand Up @@ -381,7 +373,7 @@ const entriesWithoutCookieAndLocalStorage = {
type: 'sessionStorage',
key: COOKIE_KEYS.authToken,
},
};
} as unknown as StorageEntries;

const entriesWithOnlyNoStorage = {
userId: {
Expand Down Expand Up @@ -420,7 +412,7 @@ const entriesWithOnlyNoStorage = {
type: 'none',
key: COOKIE_KEYS.authToken,
},
};
} as unknown as StorageEntries;

const entriesWithOnlySessionStorage = {
userId: {
Expand Down Expand Up @@ -459,7 +451,7 @@ const entriesWithOnlySessionStorage = {
type: 'sessionStorage',
key: COOKIE_KEYS.authToken,
},
};
} as unknown as StorageEntries;

const entriesWithMixStorage = {
userId: {
Expand Down Expand Up @@ -498,7 +490,7 @@ const entriesWithMixStorage = {
type: 'memoryStorage',
key: COOKIE_KEYS.authToken,
},
};
} as unknown as StorageEntries;

const entriesWithMixStorageButWithoutNone = {
userId: {
Expand Down Expand Up @@ -537,7 +529,7 @@ const entriesWithMixStorageButWithoutNone = {
type: 'memoryStorage',
key: COOKIE_KEYS.authToken,
},
};
} as unknown as StorageEntries;

const loadOptionWithEntry = {
userId: {
Expand Down Expand Up @@ -606,7 +598,7 @@ const entriesWithInMemoryFallback = {
type: 'memoryStorage',
key: COOKIE_KEYS.authToken,
},
};
} as unknown as StorageEntries;

const loadOptionWithInvalidEntry = {
userId: {
Expand Down Expand Up @@ -657,7 +649,7 @@ const entriesWithStorageOnlyForSession = {
type: 'none',
key: COOKIE_KEYS.authToken,
},
};
} as unknown as StorageEntries;

const anonymousIdWithNoStorageEntries = {
userId: {
Expand Down Expand Up @@ -696,7 +688,7 @@ const anonymousIdWithNoStorageEntries = {
type: 'cookieStorage',
key: COOKIE_KEYS.authToken,
},
};
} as unknown as StorageEntries;

const entriesWithStorageOnlyForAnonymousId = {
userId: {
Expand Down Expand Up @@ -735,7 +727,7 @@ const entriesWithStorageOnlyForAnonymousId = {
type: 'none',
key: COOKIE_KEYS.authToken,
},
};
} as unknown as StorageEntries;

export {
identifyRequestPayload,
Expand Down
Loading

0 comments on commit bd79c67

Please sign in to comment.