-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: integrate vitest matchers globally (#3425)
* feat: integrate vitest matchers globally * fix: added global type file & changed setup file directory * docs: improve `cookbook/transaction-request` (#3440) * chore: silence recipes format logs (#3451) * chore: silence recipe logs * chore: update changeset * docs: fix api links (#3452) * docs: fixing API links * chore: fixing relative links * fix: `transferToContract` method now allows big numbers (#3458) * fix: incorrectly converting BN to number for `formatTransferToContractScriptData` * chore: changeset * chore: tests * chore: added test for batch transfer * fix: moved vitest matcher setup from fuel-gauge to utils * fix(utils): update vitest matcher import path * chore: add changeset for vitest matcher changes * fix: removed previous changeset * chore: removed types * chore: added changeset * Update .changeset/rare-hornets-rush.md --------- Co-authored-by: Sérgio Torres <[email protected]> Co-authored-by: Daniel Bate <[email protected]> Co-authored-by: Peter Smith <[email protected]>
- Loading branch information
1 parent
a3842a5
commit 896bf5b
Showing
7 changed files
with
47 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@fuel-ts/utils": patch | ||
--- | ||
|
||
chore: integrate vitest matchers globally |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { bn } from '@fuel-ts/math'; | ||
import type { BN, BNInput } from '@fuel-ts/math'; | ||
|
||
interface Matchers<R = BN> { | ||
toEqualBn: (expected: BNInput) => R; | ||
} | ||
declare module 'vitest' { | ||
interface Assertion extends Matchers {} | ||
interface AsymmetricMatchersContaining extends Matchers {} | ||
interface ExpectStatic { | ||
toEqualBn(expected: BNInput): BN; | ||
} | ||
} | ||
|
||
export const setupTestMatchers = () => { | ||
expect.extend({ | ||
toEqualBn(received: BNInput, expected: BNInput) { | ||
const actualBn = bn(received); | ||
const expectedBn = bn(expected); | ||
const pass = actualBn.eq(expectedBn); | ||
|
||
if (pass) { | ||
return { | ||
pass, | ||
message: () => `Expected ${actualBn} not to equal ${expectedBn}`, | ||
actual: actualBn, | ||
}; | ||
} | ||
|
||
return { | ||
pass, | ||
message: () => `Expected ${actualBn} to equal ${expectedBn}`, | ||
actual: expectedBn, | ||
}; | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { setupTestMatchers } from '@fuel-ts/utils/test-utils'; | ||
|
||
setupTestMatchers(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters