Skip to content

Commit

Permalink
Replace expect with assert (#541)
Browse files Browse the repository at this point in the history
* Replace expect with assert

Expect relies on node APIs that make it difficult to do browser testing.
We will add browser testing in an upcoming PR.

* Check fs.transaction only called once
  • Loading branch information
bgins committed Jul 31, 2023
1 parent 91c8374 commit c717b19
Show file tree
Hide file tree
Showing 9 changed files with 480 additions and 462 deletions.
90 changes: 89 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@
"@types/node": "^18.14.6",
"@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0",
"assert": "^2.0.0",
"copyfiles": "^2.4.1",
"dprint": "^0.39.0",
"esbuild": "^0.17.11",
"eslint": "^8.35.0",
"expect": "^27.0.0",
"fast-check": "^3.7.0",
"globby": "^13.1.3",
"madge": "^6.0.0",
Expand Down
12 changes: 5 additions & 7 deletions src/common/crypto.node.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import expect from "expect"
import { strict as assert } from "assert"

import * as Crypto from "./crypto.js"

Expand All @@ -8,13 +8,12 @@ describe("Crypto", async () => {
const key = await Crypto.rsa.generateKey("sign")
const signature = await Crypto.rsa.sign(data, key)

expect(
assert.equal(
await Crypto.rsa.verify({
message: data,
publicKey: await Crypto.exportPublicKey(key),
signature: signature,
})
).toBe(
}),
true
)
})
Expand All @@ -24,11 +23,10 @@ describe("Crypto", async () => {
const key = await Crypto.rsa.generateKey("exchange")
const encrypted = await Crypto.rsa.encrypt(data, key.publicKey)

expect(
assert.equal(
await Crypto.rsa.decrypt(encrypted, key.privateKey).then(
a => new TextDecoder().decode(a)
)
).toBe(
),
"🙈"
)
})
Expand Down
Loading

0 comments on commit c717b19

Please sign in to comment.