Skip to content

Commit

Permalink
Fix "a" matcher for functions (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
krzkaczor authored Mar 6, 2022
1 parent 1879ba2 commit fde9d67
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/quiet-dots-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'earljs': patch
---

Fixed "a" matcher for functions
2 changes: 2 additions & 0 deletions packages/earljs/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export type Class2Primitive<T> = T extends String
? bigint
: T extends Symbol
? symbol
: T extends Function
? () => any
: T extends Exact<Object, T>
? any
: T extends Array<any>
Expand Down
5 changes: 5 additions & 0 deletions packages/earljs/test/matchers/A.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,10 @@ describe('A matcher', () => {
it('works with arrays', () => {
earlExpect([1, 2, 3]).toEqual(earlExpect.a(Array))
})

it('works with functions', () => {
// repro for #178
earlExpect((v: number) => v + 1).toEqual(earlExpect.a(Function))
})
})
})

0 comments on commit fde9d67

Please sign in to comment.