Skip to content

Commit

Permalink
address workshop feedback (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito authored Nov 18, 2024
1 parent 2bf2a8c commit 522edbc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
4 changes: 2 additions & 2 deletions exercises/03.date-and-time/01.solution.date-time/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ afterAll(() => {

Calling `vi.useFakeTimers()` detached this test from the real flow of time, and makes it rely on the internal fake date Vitest has. Correspondingly, the `vi.useRealTimers()` utility undoes that.

To fix date and time in test, I will call `vi.useSystemTime()` function and provide it with the date that I want to be treated as `Date.now()`:
To fix date and time in test, I will call `vi.setSystemTime()` function and provide it with the date that I want to be treated as `Date.now()`:

```ts filename=get-relative-time.test.ts nonumber lines=2
test('returns "Just now" for the current date', () => {
vi.setSystemTime(new Date('2024-06-01 00:00:00.000Z'))
```
> :owl: `vi.useSystemTime()` only works in conjunction with `vi.useFakeTimers()`.
> :owl: `vi.setSystemTime()` only works in conjunction with `vi.useFakeTimers()`.
In order to model the "Just now" scenario, the delta between the current time and the start time has to be 60 seconds or less. In this test, I will pass the exact same date to the `getRelativeTime()` function as the system time:
Expand Down
7 changes: 0 additions & 7 deletions exercises/05.network/04.solution.network-errors/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ test('handles network errors', async () => {
return Response.error()
}),
)

await expect(() =>
getAuthToken({
email: '[email protected]',
password: 'supersecret123',
}),
).rejects.toThrow('Authentication failed: network error')
})
```

Expand Down

0 comments on commit 522edbc

Please sign in to comment.