chai-uuid
Advanced tools
Comparing version 1.0.3 to 1.0.4
14
index.js
@@ -12,3 +12,3 @@ 'use strict'; | ||
function getRegEx(version) { | ||
switch(version) | ||
switch(version.toLowerCase()) | ||
{ | ||
@@ -31,6 +31,6 @@ case 'v1': | ||
/** | ||
* Validates a UUID | ||
* Validates a uuid | ||
* @param {String} version | ||
*/ | ||
Assertion.addMethod('uuid', function(version) { | ||
function uuid(version) { | ||
const v = (version) ? version : ''; | ||
@@ -53,4 +53,8 @@ | ||
'expected #{this} to not be a UUID ' + v | ||
); | ||
}); | ||
); | ||
} | ||
// expose methods for chai | ||
Assertion.addMethod('uuid', uuid) | ||
Assertion.addMethod('guid', uuid) | ||
}; |
{ | ||
"name": "chai-uuid", | ||
"version": "1.0.3", | ||
"description": "Chai plugin for performing assertions on UUID strings", | ||
"version": "1.0.4", | ||
"description": "Chai plugin for performing assertions on UUIDs", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "directories": { |
# chai-uuid | ||
Chai plugin for performing assertions on UUID strings | ||
Chai plugin for performing assertions on UUIDs | ||
@@ -10,3 +10,3 @@ ## Install | ||
## Example | ||
Use the `uuid` method to test whether the assertion is a valid UUID. | ||
Use the `uuid` or `guid` method to test whether the assertion is a valid UUID. | ||
@@ -31,2 +31,5 @@ ```javascript | ||
expect('a416d989-91d1-48c9-b583-267df138834c').to.be.a.uuid(); | ||
// optionally, you can use the guid method | ||
expect('a416d989-91d1-48c9-b583-267df138834c').to.be.a.guid(); | ||
``` |
@@ -16,2 +16,6 @@ const chai = require('chai'); | ||
}); | ||
it('should successfully validate a UUID (any version) using the "guid" method', function() { | ||
expect(uuid).to.be.a.guid(); | ||
}); | ||
}); | ||
@@ -18,0 +22,0 @@ |
8427
157
34