Skip to content

Commit

Permalink
Fix random id not being stubbed (#6)
Browse files Browse the repository at this point in the history
* 1.0.9

* Stub crypto only if it's not globally available

* Use mock random uuid on newer node versions, as well
  • Loading branch information
kuba-orlik authored Dec 11, 2023
1 parent 98cb605 commit 955566b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/requestBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import { getToolRequest } from './requestBuilder'

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

const mock_random_id = '2006998272.1617012296'

if (!global.crypto) {
vi.stubGlobal('crypto', {
randomUUID: () => {
return '2006998272.1617012296'
return mock_random_id
},
})
} else {
crypto.randomUUID = () => mock_random_id
}

describe('getToolRequest', () => {
Expand Down

0 comments on commit 955566b

Please sign in to comment.