Skip to content

Commit 04499fa

Browse files
committed
remove logs and warnings from test file
1 parent e0d5769 commit 04499fa

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/integrationTests/async.spec.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ let uid2: UID2;
99
let xhrMock: any;
1010
mocks.setupFakeTime();
1111

12+
beforeAll(() => {
13+
mocks.setWarnMock();
14+
});
15+
16+
afterAll(() => {
17+
mocks.clearWarnMock();
18+
});
19+
1220
beforeEach(() => {
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
});

src/mocks.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { Identity } from './Identity';
44
import { base64ToBytes, bytesToBase64 } from './encoding/base64';
55
import * as crypto from 'crypto';
66
import { ProductDetails } from './product';
7-
7+
import { MockInstance } from 'jest-mock';
8+
import { jest as jestGlobal } from '@jest/globals';
89
const uid2LocalStorageKeyName = 'UID2-sdk-identity';
910
const 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+
}

0 commit comments

Comments
 (0)