Skip to content

Commit 20a0b23

Browse files
committed
02/02: fix failing assertion
1 parent 4914bff commit 20a0b23

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

exercises/02.context/02.solution.automatic-fixtures/README.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ test('returns the user by id', async ({ createMockDatabase }) => {
5151
await createMockDatabase((db, done) => {
5252
db.run(
5353
'INSERT INTO users (id, name) VALUES (?, ?)',
54-
['abc-123', 'John Doe'],
54+
['abc-123', 'John Maverick'],
5555
done,
5656
)
5757
})
5858

5959
await expect(queryUser('abc-123')).resolves.toEqual({
6060
id: 'abc-123',
61-
name: 'John Doe',
61+
name: 'John Maverick',
6262
})
6363
})
6464
```
6565

66-
The database fixture conveniently accepts a function that I can use to interact with the mock database. In the case above, I am injecting a row into the `users` table with id `'abc-123'` and name `'John Doe'`.
66+
The database fixture conveniently accepts a function that I can use to interact with the mock database. In the case above, I am injecting a row into the `users` table with id `'abc-123'` and name `'John Maverick'`.
6767

6868
> The `done()` callback is there because the SQLite implementation I'm using isn't Promise-friendly. You can disregard that part since it's not important for us today.
6969
@@ -88,15 +88,15 @@ Like in the `createMockDatabase()` fixture, if it detects a failing test, it wil
8888

8989
```txt nonumber highlight=23-25
9090
FAIL src/query-user.test.ts > returns the user by id
91-
AssertionError: expected { id: 'abc-123', name: 'John Doe' } to deeply equal { id: 'abc-123', …(1) }
91+
AssertionError: expected { id: 'abc-123', name: 'John Maverick' } to deeply equal { id: 'abc-123', …(1) }
9292
9393
- Expected
9494
+ Received
9595
9696
{
9797
"id": "abc-123",
98-
- "name": "Kate McMaverick",
99-
+ "name": "John Doe",
98+
- "name": "Kate Smith",
99+
+ "name": "John Maverick",
100100
}
101101
102102
❯ src/query-user.test.ts:17:2
@@ -105,7 +105,7 @@ AssertionError: expected { id: 'abc-123', name: 'John Doe' } to deeply equal { i
105105
17| await expect(queryUser('abc-123')).resolves.toEqual({
106106
| ^
107107
18| id: 'abc-123',
108-
19| name: 'Kate McMaverick',
108+
19| name: 'Kate Smith',
109109
110110
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯
111111

exercises/02.context/02.solution.automatic-fixtures/src/query-user.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ test('returns the user by id', async ({ createMockDatabase }) => {
99
await createMockDatabase((db, done) => {
1010
db.run(
1111
'INSERT INTO users (id, name) VALUES (?, ?)',
12-
['abc-123', 'John Doe'],
12+
['abc-123', 'John Maverick'],
1313
done,
1414
)
1515
})
1616

1717
await expect(queryUser('abc-123')).resolves.toEqual({
1818
id: 'abc-123',
19-
name: 'Kate McMaverick',
19+
name: 'John Maverick',
2020
})
2121
})

0 commit comments

Comments
 (0)