-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Jimo): prevent losing ref of client (#2392)
* fix(Jimo): prevent losing ref of client * fix(Jimo): tests
- Loading branch information
Showing
6 changed files
with
53 additions
and
32 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,11 @@ import { Payload } from '../generated-types' | |
|
||
describe('Jimo - Send User Data', () => { | ||
test('user id', async () => { | ||
const mockedPush = jest.fn() | ||
const segmentJimo = { | ||
client: { push: jest.fn() } | ||
client() { | ||
return { push: mockedPush } | ||
} | ||
} as any as JimoClient | ||
|
||
const context = new Context({ | ||
|
@@ -23,12 +26,15 @@ describe('Jimo - Send User Data', () => { | |
} as Payload | ||
}) | ||
|
||
expect(segmentJimo.client.push).toHaveBeenCalled() | ||
expect(segmentJimo.client.push).toHaveBeenCalledWith(['do', 'identify', ['u1', expect.any(Function)]]) | ||
expect(segmentJimo.client().push).toHaveBeenCalled() | ||
expect(segmentJimo.client().push).toHaveBeenCalledWith(['do', 'identify', ['u1', expect.any(Function)]]) | ||
}) | ||
test('user id then email and attributes', async () => { | ||
const mockedPush = jest.fn() | ||
const segmentJimo = { | ||
client: { push: jest.fn() } | ||
client() { | ||
return { push: mockedPush } | ||
} | ||
} as any as JimoClient | ||
|
||
const context = new Context({ | ||
|
@@ -48,12 +54,15 @@ describe('Jimo - Send User Data', () => { | |
} as Payload | ||
}) | ||
|
||
expect(segmentJimo.client.push).toHaveBeenCalled() | ||
expect(segmentJimo.client.push).toHaveBeenCalledWith(['do', 'identify', ['u1', expect.any(Function)]]) | ||
expect(segmentJimo.client().push).toHaveBeenCalled() | ||
expect(segmentJimo.client().push).toHaveBeenCalledWith(['do', 'identify', ['u1', expect.any(Function)]]) | ||
}) | ||
test('user email', async () => { | ||
const mockedPush = jest.fn() | ||
const segmentJimo = { | ||
client: { push: jest.fn() } | ||
client() { | ||
return { push: mockedPush } | ||
} | ||
} as any as JimoClient | ||
|
||
const context = new Context({ | ||
|
@@ -69,12 +78,15 @@ describe('Jimo - Send User Data', () => { | |
} as Payload | ||
}) | ||
|
||
expect(segmentJimo.client.push).toHaveBeenCalled() | ||
expect(segmentJimo.client.push).toHaveBeenCalledWith(['set', 'user:email', ['[email protected]']]) | ||
expect(segmentJimo.client().push).toHaveBeenCalled() | ||
expect(segmentJimo.client().push).toHaveBeenCalledWith(['set', 'user:email', ['[email protected]']]) | ||
}) | ||
test('user traits', async () => { | ||
const mockedPush = jest.fn() | ||
const segmentJimo = { | ||
client: { push: jest.fn() } | ||
client() { | ||
return { push: mockedPush } | ||
} | ||
} as any as JimoClient | ||
|
||
const context = new Context({ | ||
|
@@ -94,8 +106,8 @@ describe('Jimo - Send User Data', () => { | |
} as Payload | ||
}) | ||
|
||
expect(segmentJimo.client.push).toHaveBeenCalled() | ||
expect(segmentJimo.client.push).toHaveBeenCalledWith([ | ||
expect(segmentJimo.client().push).toHaveBeenCalled() | ||
expect(segmentJimo.client().push).toHaveBeenCalledWith([ | ||
'set', | ||
'user:attributes', | ||
[ | ||
|
@@ -110,8 +122,11 @@ describe('Jimo - Send User Data', () => { | |
]) | ||
}) | ||
test('user traits with experience refetching', async () => { | ||
const mockedPush = jest.fn() | ||
const segmentJimo = { | ||
client: { push: jest.fn() } | ||
client() { | ||
return { push: mockedPush } | ||
} | ||
} as any as JimoClient | ||
|
||
const context = new Context({ | ||
|
@@ -131,8 +146,8 @@ describe('Jimo - Send User Data', () => { | |
} as Payload | ||
}) | ||
|
||
expect(segmentJimo.client.push).toHaveBeenCalled() | ||
expect(segmentJimo.client.push).toHaveBeenCalledWith([ | ||
expect(segmentJimo.client().push).toHaveBeenCalled() | ||
expect(segmentJimo.client().push).toHaveBeenCalledWith([ | ||
'set', | ||
'user:attributes', | ||
[ | ||
|
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