Skip to content

Commit

Permalink
Adds a test for #17
Browse files Browse the repository at this point in the history
  • Loading branch information
jchook committed Jun 24, 2020
1 parent 14aca40 commit 06ca8aa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ for (i = 0; i<10000; i++) {
assert(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(uuid()));
}

// Check the test function on known-valid UUIDs
const healthyUuid = '920b70bf-168a-458d-81ac-50e488e5976f'
assert(uuid.test(healthyUuid) === true)
assert(uuid.test(healthyUuid.toUpperCase()) === true)

// Clear the buffer and change the randomBytes function to return 0s
uuid.clearBuffer();
uuid.randomBytes = function(length) {
return (new Array(length)).fill(0, 0, length);
};
assert(uuid() === '00000000-0000-4000-8000-000000000000');

0 comments on commit 06ca8aa

Please sign in to comment.