Skip to content

Commit

Permalink
test: add sanity checks for .name, .version and .platform (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphtheninja authored and vweevers committed Feb 14, 2018
1 parent 45821f9 commit 23a5791
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.1",
"description": "Reusable list of browsers to test against when using Airtap",
"scripts": {
"test": "standard"
"test": "standard && node test.js"
},
"repository": "airtap/browsers",
"keywords": [
Expand All @@ -19,6 +19,7 @@
},
"homepage": "https://github.com/airtap/browsers",
"devDependencies": {
"standard": "~10.0.3"
"standard": "~10.0.3",
"tape": "^4.8.0"
}
}
21 changes: 21 additions & 0 deletions test.js
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()
})

0 comments on commit 23a5791

Please sign in to comment.