-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Expose Integration Name to Kit Object #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -317,6 +317,93 @@ describe('Rokt Forwarder', () => { | |
| ); | ||
| }); | ||
|
|
||
| it('should set integrationName on kit instance after attaching', async () => { | ||
| window.Rokt = new MockRoktForwarder(); | ||
| window.mParticle.Rokt = window.Rokt; | ||
| window.mParticle.Rokt.attachKitCalled = false; | ||
|
|
||
| window.mParticle.Rokt.attachKit = async (kit) => { | ||
| window.mParticle.Rokt.attachKitCalled = true; | ||
| window.mParticle.Rokt.kit = kit; | ||
| return Promise.resolve(); | ||
| }; | ||
|
|
||
| await mParticle.forwarder.init( | ||
| { | ||
| accountId: '123456', | ||
| }, | ||
| reportService.cb, | ||
| true | ||
| ); | ||
|
|
||
| // Wait for initialization to complete | ||
| await waitForCondition(() => window.mParticle.Rokt.isInitialized); | ||
|
|
||
| window.mParticle.Rokt.kit.integrationName.should.equal( | ||
| `${sdkVersion}_${kitVersion}` | ||
| ); | ||
| }); | ||
|
|
||
| it('should set integrationName on kit instance with custom name when provided', async () => { | ||
| const customName = 'myCustomName'; | ||
|
|
||
| window.Rokt = new MockRoktForwarder(); | ||
| window.mParticle.Rokt = window.Rokt; | ||
| window.mParticle.Rokt.attachKitCalled = false; | ||
|
|
||
| window.mParticle.Rokt.attachKit = async (kit) => { | ||
| window.mParticle.Rokt.attachKitCalled = true; | ||
| window.mParticle.Rokt.kit = kit; | ||
| return Promise.resolve(); | ||
| }; | ||
|
|
||
| window.mParticle.Rokt.launcherOptions = { | ||
| integrationName: customName, | ||
| }; | ||
|
|
||
| await mParticle.forwarder.init( | ||
| { | ||
| accountId: '123456', | ||
| }, | ||
| reportService.cb, | ||
| true | ||
| ); | ||
|
|
||
| // Wait for initialization to complete | ||
| await waitForCondition(() => window.mParticle.Rokt.isInitialized); | ||
|
|
||
| window.mParticle.Rokt.kit.integrationName.should.equal( | ||
| `${sdkVersion}_${kitVersion}_${customName}` | ||
| ); | ||
|
Comment on lines
+372
to
+377
|
||
| }); | ||
|
|
||
| it('should have integrationName available on kit after initialization', async () => { | ||
| window.Rokt = new MockRoktForwarder(); | ||
| window.mParticle.Rokt = window.Rokt; | ||
| window.mParticle.Rokt.attachKitCalled = false; | ||
|
|
||
| window.mParticle.Rokt.attachKit = async (kit) => { | ||
| window.mParticle.Rokt.attachKitCalled = true; | ||
| window.mParticle.Rokt.kit = kit; | ||
| return Promise.resolve(); | ||
| }; | ||
|
|
||
| await mParticle.forwarder.init( | ||
| { | ||
| accountId: '123456', | ||
| }, | ||
| reportService.cb, | ||
| true | ||
| ); | ||
|
|
||
| // Wait for initialization to complete | ||
| await waitForCondition(() => window.mParticle.Rokt.isInitialized); | ||
|
|
||
| window.mParticle.Rokt.attachKitCalled.should.equal(true); | ||
| window.mParticle.Rokt.kit.integrationName.should.be.a.String(); | ||
| window.mParticle.Rokt.kit.integrationName.should.not.be.empty(); | ||
| }); | ||
|
Comment on lines
+399
to
+405
|
||
|
|
||
| it('should not mutate the global launcherOptions object during initialization', async () => { | ||
| const originalIntegrationName = 'globalIntegrationName'; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These assertions rely on
waitForCondition(() => window.mParticle.Rokt.isInitialized), butMockRoktForwarder.createLaunchersetsisInitialized = truebefore the kit is actually attached. This can make the test race/flaky ifattachKitruns later. Consider waiting onwindow.mParticle.Rokt.attachKitCalled(orwindow.mParticle.forwarder.isInitialized, orwindow.mParticle.Rokt.kitbeing set) instead so the kit is guaranteed available before assertingkit.integrationName.