-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add webcrypto node.js + browser tests
- Loading branch information
Showing
5 changed files
with
59 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,12 @@ | ||
// @vitest-environment happy-dom | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import webcrypto from './browser.js'; | ||
|
||
describe('@acusti/webcrypto', () => { | ||
describe('browser.ts', () => { | ||
it('exports node:crypto’s webcrypto object', () => { | ||
expect(webcrypto).toBe(window.crypto); | ||
}); | ||
}); | ||
}); |
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,19 @@ | ||
import crypto from 'node:crypto'; | ||
|
||
import { describe, expect, it } from 'vitest'; | ||
|
||
import webcrypto from './node.js'; | ||
|
||
describe('@acusti/webcrypto', () => { | ||
describe('node.ts', () => { | ||
it('exports node:crypto’s webcrypto object', () => { | ||
expect(webcrypto).toBe(crypto.webcrypto); | ||
}); | ||
|
||
it('works in a node environment (as opposed to browser.js, which throws an error)', async () => { | ||
await expect(() => import('./browser.js')).rejects.toThrowError( | ||
'not defined', | ||
); | ||
}); | ||
}); | ||
}); |
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