Skip to content

Commit dc38026

Browse files
added cookie example also
1 parent 7aa9c23 commit dc38026

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/integrationTests/options.test.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -611,15 +611,14 @@ describe('calls the NoIdentityAvailable event', () => {
611611

612612
expect(handler).toHaveBeenLastCalledWith(EventType.NoIdentityAvailable, { identity: null });
613613
});
614-
test('when get identity returns null or get advertising token returns undefined', () => {
614+
test('when get identity returns null', () => {
615615
uid2.getIdentity();
616616

617617
expect(handler).toHaveBeenLastCalledWith(EventType.NoIdentityAvailable, { identity: null });
618618
});
619619
test('when there is no advertising token', () => {
620-
const token = uid2.getAdvertisingToken();
620+
uid2.getAdvertisingToken();
621621

622-
expect(token).toBeUndefined();
623622
expect(handler).toHaveBeenLastCalledWith(EventType.NoIdentityAvailable, { identity: null });
624623
});
625624
test('when cstg does not succeed', () => {
@@ -670,9 +669,7 @@ describe('does not call NoIdentityAvailable event', () => {
670669
expect(handler).not.toHaveBeenLastCalledWith(EventType.NoIdentityAvailable, { identity: null });
671670
});
672671
test('when identity is set with opted out identity', () => {
673-
uid2.init({});
674-
let optedOutIdentity = makeIdentity({ status: 'optout' });
675-
uid2.setIdentity(optedOutIdentity);
672+
uid2.init({ identity: makeIdentity({ status: 'optout' }) });
676673

677674
expect(handler).not.toHaveBeenLastCalledWith(EventType.NoIdentityAvailable, { identity: null });
678675
});
@@ -685,10 +682,16 @@ describe('does not call NoIdentityAvailable event', () => {
685682
}).not.toThrow();
686683
expect(handler).not.toHaveBeenLastCalledWith(EventType.NoIdentityAvailable, { identity: null });
687684
});
688-
test('when identity is set with local storage and init has never been', () => {
685+
test('when identity is set with local storage and init has never been called', () => {
689686
mocks.setUid2LocalStorage(validIdentity);
690687
uid2.isIdentityAvailable();
691688

689+
expect(handler).not.toHaveBeenLastCalledWith(EventType.NoIdentityAvailable, { identity: null });
690+
});
691+
test('when identity is set with cookie and init has never been called', () => {
692+
mocks.setUid2Cookie(validIdentity);
693+
uid2.isIdentityAvailable();
694+
692695
expect(handler).not.toHaveBeenLastCalledWith(EventType.NoIdentityAvailable, { identity: null });
693696
});
694697
});

0 commit comments

Comments
 (0)