From 23a5791fd8b55e3b275fda6fbcb2b4d519dca718 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Wed, 14 Feb 2018 09:15:50 +0100 Subject: [PATCH] test: add sanity checks for .name, .version and .platform (#6) --- package.json | 5 +++-- test.js | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 test.js diff --git a/package.json b/package.json index 3a1007f..cacddf8 100644 --- a/package.json +++ b/package.json @@ -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": [ @@ -19,6 +19,7 @@ }, "homepage": "https://github.com/airtap/browsers", "devDependencies": { - "standard": "~10.0.3" + "standard": "~10.0.3", + "tape": "^4.8.0" } } diff --git a/test.js b/test.js new file mode 100644 index 0000000..100b8f4 --- /dev/null +++ b/test.js @@ -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() +})