-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
789 additions
and
657 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@segment/analytics-next': patch | ||
--- | ||
|
||
Add 'disable' boolean option to allow for disabling Segment in a testing environment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
38 changes: 38 additions & 0 deletions
38
packages/browser/src/core/analytics/__tests__/null-analytics.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { getAjsBrowserStorage } from '../../../test-helpers/browser-storage' | ||
import { Analytics } from '../analytics' | ||
import { NullAnalytics } from '../null-analytics' | ||
|
||
describe(NullAnalytics, () => { | ||
it('should return an instance of Analytics / NullAnalytics', () => { | ||
const analytics = new NullAnalytics() | ||
expect(analytics).toBeInstanceOf(Analytics) | ||
expect(analytics).toBeInstanceOf(NullAnalytics) | ||
}) | ||
|
||
it('should have initialized set to true', () => { | ||
const analytics = new NullAnalytics() | ||
expect(analytics.initialized).toBe(true) | ||
}) | ||
|
||
it('should have no plugins', async () => { | ||
const analytics = new NullAnalytics() | ||
expect(analytics.queue.plugins).toHaveLength(0) | ||
}) | ||
it('should dispatch events', async () => { | ||
const analytics = new NullAnalytics() | ||
const ctx = await analytics.track('foo') | ||
expect(ctx.event.event).toBe('foo') | ||
}) | ||
|
||
it('should have disableClientPersistence set to true', () => { | ||
const analytics = new NullAnalytics() | ||
expect(analytics.options.disableClientPersistence).toBe(true) | ||
}) | ||
|
||
it('integration: should not touch cookies or localStorage', async () => { | ||
const analytics = new NullAnalytics() | ||
await analytics.track('foo') | ||
const storage = getAjsBrowserStorage() | ||
expect(Object.values(storage).every((v) => !v)).toBe(true) | ||
}) | ||
}) |
Oops, something went wrong.