Skip to content

Commit

Permalink
test: case with real timer
Browse files Browse the repository at this point in the history
  • Loading branch information
vitonsky committed Aug 3, 2024
1 parent 0bcfdcd commit dda80f9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Estimate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,19 @@ describe('basic usage', () => {
);
});
});

describe('cases with real timer', () => {
test('100 steps to complete', () => {
const estimate = new Estimate({ timeFetcher: () => performance.now() });

for (
let state = { progress: 1, total: 100 };
state.progress <= state.total;
state.progress += 1
) {
const measures = estimate.update(state.progress, state.total);
expect(measures.speed).toBeGreaterThan(1000);
expect(measures.averageTime).toBeLessThan(0.5);
}
});
});

0 comments on commit dda80f9

Please sign in to comment.