Skip to content

Commit

Permalink
Also verify id fields are formatted as UUIDs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Leshana committed Sep 7, 2019
1 parent e0ed109 commit 270addf
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
const assert = require('assert');
const fs = require('fs');
const UUID_REGEX = /^[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}$/;

// NOTE: Mocha supports dynamically generated "parameterzied" tests, but not when the test cases are obtained dynamically.
// Therefore we must fetch the list of files to test on synchronously before we begin. Ah well.
Expand Down Expand Up @@ -42,6 +43,7 @@ describe("JSON Data Files", function() {
fileData.forEach((dataItem, i) => {
("id" in dataItem) || assert.fail(`Item ${i} in ${fileName} missing id`);
(dataItem.id != '') || assert.fail(`Item ${i} in ${fileName} has blank id`);
(UUID_REGEX.test(dataItem.id)) || assert.fail(`Item ${i} in ${fileName} is not a UUID`);
});
}
});
Expand Down

0 comments on commit 270addf

Please sign in to comment.