Skip to content

Commit

Permalink
Add suggested test
Browse files Browse the repository at this point in the history
  • Loading branch information
richardm-stripe committed Oct 18, 2022
1 parent fb3ce90 commit d52c170
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,24 @@ describe('utils', () => {
});

describe('uuid', () => {

describe('crypto.randomUUID', () => {
const crypto = require('crypto')
let randomUUID$
let called
beforeEach(() => {
called = false
randomUUID$ = crypto.randomUUID
crypto.randomUUID = () => (called = true, "no, YOU you id")
})
afterEach(() => {
crypto.randomUUID = randomUUID$
})
it('is called if available', () => {
expect(utils.uuid4()).to.equal("no, YOU you id");
expect(called).to.equal(true)
})
})
it('should return a well-formatted v4 UUID', () => {
expect(utils.uuid4()).to.match(
// regex from https://createuuid.com/validator/, specifically for v4
Expand Down

0 comments on commit d52c170

Please sign in to comment.