Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich committed Jun 6, 2024
1 parent 849678c commit 91f8c4c
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/tracing/timetodisplay.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,42 @@ describe('TimeToDisplay', () => {
expect(spanToJSON(fullDisplaySpan!).timestamp).toEqual(initialDisplayEndTimestampMs / 1_000);
});

test('full display which ended before but processed after initial display is extended to initial display end', async () => {
const fullDisplayEndTimestampMs = secondInFutureTimestampMs();
const initialDisplayEndTimestampMs = secondInFutureTimestampMs() + 500;
const [initialDisplaySpan, fullDisplaySpan, activeSpan] = startSpanManual(
{
name: 'Root Manual Span',
startTime: secondAgoTimestampMs(),
},
(activeSpan: Span | undefined) => {
const initialDisplaySpan = startTimeToInitialDisplaySpan();
const fullDisplaySpan = startTimeToFullDisplaySpan();

const timeToDisplayComponent = TestRenderer.create(<><TimeToInitialDisplay record={false} /><TimeToFullDisplay record={true}/></>);
timeToDisplayComponent.update(<><TimeToInitialDisplay record={true} /><TimeToFullDisplay record={true} /></>);

emitNativeInitialDisplayEvent(initialDisplayEndTimestampMs);
emitNativeFullDisplayEvent(fullDisplayEndTimestampMs);

activeSpan?.end();
return [initialDisplaySpan, fullDisplaySpan, activeSpan];
},
);

await jest.runOnlyPendingTimersAsync();
await client.flush();

expectFinishedInitialDisplaySpan(initialDisplaySpan, activeSpan);
expectFinishedFullDisplaySpan(fullDisplaySpan, activeSpan);

expectInitialDisplayMeasurementOnSpan(client.event!);
expectFullDisplayMeasurementOnSpan(client.event!);

expect(spanToJSON(initialDisplaySpan!).timestamp).toEqual(initialDisplayEndTimestampMs / 1_000);
expect(spanToJSON(fullDisplaySpan!).timestamp).toEqual(initialDisplayEndTimestampMs / 1_000);
});

test('consequent renders do not update display end', async () => {
const initialDisplayEndTimestampMs = secondInFutureTimestampMs();
const fullDisplayEndTimestampMs = secondInFutureTimestampMs() + 500;
Expand Down

0 comments on commit 91f8c4c

Please sign in to comment.