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 e071567
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,26 @@ 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;
return '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 e071567

Please sign in to comment.