Skip to content

Commit 0eb5c01

Browse files
committed
03/02: simplify the exercise
1 parent 20add75 commit 0eb5c01

File tree

6 files changed

+7
-51
lines changed

6 files changed

+7
-51
lines changed

β€Žexercises/03.assertions/02.problem.asymmetric-matchers/src/fetch-transaction.test.tsβ€Ž

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@ import { fetchTransaction, type Transaction } from './fetch-transaction'
22
import { userSchema } from './schemas'
33

44
test('fetches a transaction between two users', async () => {
5-
// 🐨 Declare a variable called `transaction` and assign it the result
6-
// of calling `fetchTransaction` with the argument `'transaction-1'`.
7-
// Notice that the `fetchTransaction` function returns a promise.
8-
// πŸ’° const foo = await bar()
9-
//
10-
// 🐨 Next, write an assertion that the returned `transaction` equals
11-
// a transaction object. Such an object has the following properties:
12-
// - `id` equal to `'transaction-1'`;
13-
// - `issuer` that matches the `userSchema` schema;
14-
// - `recipient` that matches the `userSchema` schema.
5+
const transaction = await fetchTransaction('transaction-1')
6+
7+
// 🐨 Write an assertion over the `transaction` object.
8+
// In the expected object, express that the `id` property should
9+
// equal to the transaction ID, and both `issuer` and `recipient`
10+
// properties should match the `userSchema` schema.
1511
// πŸ’° expect(transaction).toEqual<Transaction>({})
1612
// πŸ’° expect.toMatchSchema(schema)
1713
})

β€Žexercises/03.assertions/02.problem.asymmetric-matchers/src/fetch-user.test.tsβ€Ž

Lines changed: 0 additions & 9 deletions
This file was deleted.

β€Žexercises/03.assertions/02.problem.asymmetric-matchers/src/fetch-user.tsβ€Ž

Lines changed: 0 additions & 11 deletions
This file was deleted.

β€Žexercises/03.assertions/02.solution.asymmetric-matchers/src/fetch-user.test.tsβ€Ž

Lines changed: 0 additions & 7 deletions
This file was deleted.

β€Žexercises/03.assertions/02.solution.asymmetric-matchers/src/fetch-user.tsβ€Ž

Lines changed: 0 additions & 11 deletions
This file was deleted.

β€Žexercises/03.assertions/02.solution.asymmetric-matchers/vitest.setup.tsβ€Ž

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ interface CustomMatchers<MatcherResult = any> {
66
}
77

88
declare module 'vitest' {
9-
interface Assertion<T = any> extends CustomMatchers<T> {}
10-
interface MatchersDeclaration extends CustomMatchers {}
11-
interface AsymmetricMatchersContaining extends CustomMatchers {}
9+
interface Matchers<T = any> extends CustomMatchers<T> {}
1210
}
1311

1412
expect.extend({

0 commit comments

Comments
Β (0)