-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add sanity checks for .name, .version and .platform (#6)
- Loading branch information
1 parent
45821f9
commit 23a5791
Showing
2 changed files
with
24 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const test = require('tape') | ||
const browsers = require('.') | ||
|
||
test('check .name, .version and .platform', t => { | ||
t.equal(Array.isArray(browsers.all), true, '.all is an array') | ||
t.equal(Array.isArray(browsers.pullRequest), true, '.pullRequest is an array') | ||
|
||
function predicate (el) { | ||
// .name required | ||
if (typeof el.name !== 'string') return false | ||
// .platform optional, should be string if set | ||
if (el.platform && typeof el.platform !== 'string') return false | ||
// .version required | ||
return typeof el.version === 'string' || Array.isArray(el.version) | ||
} | ||
|
||
t.equal(browsers.all.every(predicate), true) | ||
t.equal(browsers.pullRequest.every(predicate), true) | ||
|
||
t.end() | ||
}) |