Skip to content

Commit

Permalink
Merge pull request #707 from retejs/fix-tests-config
Browse files Browse the repository at this point in the history
Fix tests config
  • Loading branch information
Ni55aN authored Apr 20, 2024
2 parents 5859aa8 + ce5bc04 commit cf4e897
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
8 changes: 4 additions & 4 deletions 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 @@ -28,7 +28,7 @@
},
"devDependencies": {
"jest-environment-jsdom": "^29.1.2",
"rete-cli": "^1.0.2",
"rete-cli": "^1.0.3",
"typescript": "4.8.4"
},
"dependencies": {
Expand Down
13 changes: 10 additions & 3 deletions test/mocks/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { Buffer } from 'buffer'

export function mockCrypto(object: Record<string, unknown>) {
// eslint-disable-next-line no-undef
globalThis.crypto = object as unknown as Crypto
Object.defineProperty(globalThis, 'crypto', {
value: object,
writable: true
})
}

export function mockCryptoFromArray(array: Uint8Array) {
Expand All @@ -19,6 +22,10 @@ export function mockCryptoFromBuffer(buffer: Buffer) {
}

export function resetCrypto() {
// eslint-disable-next-line no-undef, no-undefined
globalThis.crypto = undefined as unknown as Crypto
// eslint-disable-next-line no-undef
Object.defineProperty(globalThis, 'crypto', {
// eslint-disable-next-line no-undefined
value: undefined,
writable: true
})
}

0 comments on commit cf4e897

Please sign in to comment.