Skip to content

Commit 955566b

Browse files
authored
Fix random id not being stubbed (#6)
* 1.0.9 * Stub crypto only if it's not globally available * Use mock random uuid on newer node versions, as well
1 parent 98cb605 commit 955566b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/requestBuilder.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@ import { getToolRequest } from './requestBuilder'
33

44
const isInt = (num: string) => !isNaN(parseInt(num))
55

6+
const mock_random_id = '2006998272.1617012296'
7+
68
if (!global.crypto) {
79
vi.stubGlobal('crypto', {
810
randomUUID: () => {
9-
return '2006998272.1617012296'
11+
return mock_random_id
1012
},
1113
})
14+
} else {
15+
crypto.randomUUID = () => mock_random_id
1216
}
1317

1418
describe('getToolRequest', () => {

0 commit comments

Comments
 (0)