File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed
Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,14 @@ let uid2: UID2;
99let xhrMock : any ;
1010mocks . setupFakeTime ( ) ;
1111
12+ beforeAll ( ( ) => {
13+ mocks . setWarnMock ( ) ;
14+ } ) ;
15+
16+ afterAll ( ( ) => {
17+ mocks . clearWarnMock ( ) ;
18+ } ) ;
19+
1220beforeEach ( ( ) => {
1321 callback = jest . fn ( ) ;
1422 uid2 = new UID2 ( ) ;
@@ -238,14 +246,11 @@ testCookieAndLocalStorage(() => {
238246 // Reset window UID2 instance
239247 const callback = jest . fn ( ( eventType : EventType ) => {
240248 if ( eventType === UID2 . EventType . SdkLoaded ) {
241- console . log ( 'Trying' ) ;
242249 try {
243250 ( sdkWindow . __uid2 as UID2 ) . init ( { identity, useCookie : useCookie } ) ;
244251 } catch ( ex ) {
245- console . log ( ex ) ;
246252 throw ex ;
247253 }
248- console . log ( 'Succeeded' ) ;
249254 }
250255 } ) ;
251256 test ( 'the SDK should be initialized correctly' , ( ) => {
@@ -257,8 +262,6 @@ testCookieAndLocalStorage(() => {
257262 if ( ! ( sdkWindow . __uid2 instanceof UID2 ) )
258263 throw Error ( 'UID2 should be ready to use by the time SdkLoaded is triggered.' ) ;
259264 expect ( callback ) . toHaveBeenNthCalledWith ( 1 , UID2 . EventType . SdkLoaded , expect . anything ( ) ) ;
260- console . log ( sdkWindow . __uid2 . getAdvertisingToken ( ) ) ;
261- console . log ( identity . advertising_token ) ;
262265 expect ( sdkWindow . __uid2 . getAdvertisingToken ( ) ) . toBe ( identity . advertising_token ) ;
263266 } ) ;
264267 } ) ;
Original file line number Diff line number Diff line change @@ -4,7 +4,8 @@ import { Identity } from './Identity';
44import { base64ToBytes , bytesToBase64 } from './encoding/base64' ;
55import * as crypto from 'crypto' ;
66import { ProductDetails } from './product' ;
7-
7+ import { MockInstance } from 'jest-mock' ;
8+ import { jest as jestGlobal } from '@jest/globals' ;
89const uid2LocalStorageKeyName = 'UID2-sdk-identity' ;
910const euidLocalStorageKeyName = 'EUID-sdk-identity' ;
1011
@@ -419,3 +420,13 @@ export function resetCrypto(window: Window) {
419420 } ,
420421 } ) ;
421422}
423+
424+ let warnMock : MockInstance ;
425+ export function setWarnMock ( ) {
426+ warnMock = jestGlobal . spyOn ( console , 'warn' ) ;
427+ warnMock . mockImplementation ( ( ) => { } ) ;
428+ }
429+
430+ export function clearWarnMock ( ) {
431+ warnMock . mockRestore ( ) ;
432+ }
You can’t perform that action at this time.
0 commit comments