Skip to content

Commit

Permalink
[Tests] run nyc on all tests; use tape runner; add `implementatio…
Browse files Browse the repository at this point in the history
…n` tests
  • Loading branch information
ljharb committed Jan 21, 2021
1 parent 3305f03 commit c3207c1
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 8 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage/
13 changes: 13 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"lines": 86,
"statements": 85.93,
"functions": 82.43,
"branches": 76.06,
"exclude": [
"coverage",
"test"
]
}
13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@
"lint": "eslint .",
"postlint": "evalmd README.md",
"pretest": "npm run lint && es-shim-api --bound",
"test": "npm run --silent tests-only",
"test": "npm run tests-only && npm run test:promise-shimmed",
"posttest": "npx aud --production",
"tests-only": "npm run --silent test:shimmed && npm run --silent test:module && npm run --silent tests:es5",
"tests:es5": "npm run --silent test:promise-shimmed",
"test:shimmed": "node test/shimmed",
"test:module": "node test",
"test:promise-shimmed": "node test/promise-shimmed",
"test:native": "node test/native",
"coverage": "covert test/*.js"
"tests-only": "nyc tape test/{implementation,index,shimmed}.js",
"test:promise-shimmed": "nyc node test/promise-shimmed",
"test:native": "node test/native"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -71,6 +67,7 @@
"eslint": "^7.2.0",
"evalmd": "^0.0.19",
"functions-have-names": "^1.2.1",
"nyc": "^10.3.2",
"safe-publish-latest": "^1.1.4",
"tape": "^5.0.1"
},
Expand Down
30 changes: 30 additions & 0 deletions test/implementation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

var test = require('tape');
var callBind = require('call-bind');

var any = require('../implementation');
var runTests = require('./tests');

var bound = callBind(any);

// eslint-disable-next-line no-shadow
var rebindable = function any(iterable) {
// eslint-disable-next-line no-invalid-this
return bound(typeof this === 'undefined' ? Promise : this, iterable);
};

test('as a function', function (t) {
t.test('bad Promise/this value', function (st) {
// eslint-disable-next-line no-useless-call
st['throws'](function () { any.call(undefined, []); }, TypeError, 'undefined is not an object');

// eslint-disable-next-line no-useless-call
st['throws'](function () { any.call(null, []); }, TypeError, 'null is not an object');
st.end();
});

runTests(rebindable, t);

t.end();
});

0 comments on commit c3207c1

Please sign in to comment.