Skip to content

Commit

Permalink
Add a test for the idea that emissions should be weakly ascending ove…
Browse files Browse the repository at this point in the history
…r the timestamp attribute
  • Loading branch information
eoghanmurray committed Aug 10, 2021
1 parent af3d475 commit db4fbd5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/rrweb/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export function matchSnapshot(
* @param snapshots incrementalSnapshotEvent[]
*/
function stringifySnapshots(snapshots: eventWithTime[]): string {
let asc_time = 0;
return JSON.stringify(
snapshots
.filter((s) => {
Expand Down Expand Up @@ -110,6 +111,21 @@ function stringifySnapshots(snapshots: eventWithTime[]): string {
coordinatesReg.lastIndex = 0; // wow, a real wart in ECMAScript
});
}
if (
s.type === EventType.IncrementalSnapshot &&
(s.data.source === IncrementalSource.MouseMove
|| s.data.source === IncrementalSource.TouchMove
|| s.data.source === IncrementalSource.Drag)
) {
s.data.positions.forEach((p) => {
let t = s.timestamp + p.timeOffset;
assert(asc_time <= t);
asc_time = t;
});
} else {
assert(asc_time <= s.timestamp);
asc_time = s.timestamp;
}
delete s.timestamp;
return s;
}),
Expand Down

0 comments on commit db4fbd5

Please sign in to comment.