Skip to content

Commit 0db1daa

Browse files
committed
Simplify test
1 parent d853dad commit 0db1daa

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

packages/telemetry/src/api.test.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,12 @@ describe('Top level API', () => {
272272
});
273273

274274
it('should generate and store a new session ID if none exists', () => {
275+
const storage: Record<string, string> = {};
275276
const sessionStorageMock = {
276-
getItem: () => null,
277-
setItem: (_: string, __: string) => { }
278-
};
279-
sessionStorageMock.setItem = (
280-
key: string,
281-
value: string
282-
) => {
283-
// @ts-ignore
284-
sessionStorageMock[key] = value;
277+
getItem: (key: string) => storage[key] || null,
278+
setItem: (key: string, value: string) => {
279+
storage[key] = value;
280+
}
285281
};
286282
const cryptoMock = {
287283
randomUUID: () => 'new-session-id'
@@ -301,8 +297,7 @@ describe('Top level API', () => {
301297
expect(emittedLogs.length).to.equal(1);
302298
const log = emittedLogs[0];
303299
expect(log.attributes![LOG_ENTRY_ATTRIBUTE_KEYS.SESSION_ID]).to.equal('new-session-id');
304-
// @ts-ignore
305-
expect(sessionStorageMock[TELEMETRY_SESSION_ID_KEY]).to.equal(
300+
expect(storage[TELEMETRY_SESSION_ID_KEY]).to.equal(
306301
'new-session-id'
307302
);
308303
});

0 commit comments

Comments
 (0)