Skip to content

Commit

Permalink
chore: improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
williazz committed Feb 8, 2024
1 parent 1027c79 commit f595c21
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/event-cache/__tests__/EventCache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,18 +505,22 @@ describe('EventCache tests', () => {
// Init
shouldSample = false;
const EVENT1_SCHEMA = 'com.amazon.rum.event1';
const EVENT2_SCHEMA = 'com.amazon.rum.event2';
const BATCH_LIMIT = 1;
const eventCache: EventCache = Utils.createEventCache({
...DEFAULT_CONFIG,
...{ batchLimit: BATCH_LIMIT }
...DEFAULT_CONFIG
});

// Run
eventCache.recordEvent(EVENT1_SCHEMA, {});
eventCache.recordEvent(EVENT2_SCHEMA, {});
expect(eventCache.getEventBatch()).toEqual([]);

// Assert
shouldSample = true;
eventCache.recordEvent(EVENT1_SCHEMA, {});
eventCache.recordEvent(EVENT1_SCHEMA, {});
expect(eventCache.getEventBatch()).toHaveLength(2);

shouldSample = false;
eventCache.recordEvent(EVENT1_SCHEMA, {});
eventCache.recordEvent(EVENT1_SCHEMA, {});
expect(eventCache.getEventBatch()).toEqual([]);

// Restore
Expand Down

0 comments on commit f595c21

Please sign in to comment.