From 3c9330be9ad02497f78ff0fd94b7c918c3a4bc21 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sat, 21 Nov 2020 15:00:51 -0800 Subject: [PATCH] [Tests] add `implementation` test; run `es-shim-api` in postlint; use `tape` runner --- package.json | 10 +++++----- test/implementation.js | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 test/implementation.js diff --git a/package.json b/package.json index 810a3f9..729c8c6 100644 --- a/package.json +++ b/package.json @@ -14,12 +14,11 @@ "main": "index.js", "scripts": { "lint": "eslint .", - "pretest": "npm run lint && es-shim-api --bound", + "postlint": "es-shim-api --bound", + "pretest": "npm run lint", "test": "npm run tests-only", - "posttest": "npx aud --production", - "tests-only": "npm run --silent test:shimmed && npm run --silent test:module", - "test:shimmed": "node test/shimmed", - "test:module": "node test", + "posttest": "aud --production", + "tests-only": "tape 'test/**/*.js'", "version": "auto-changelog && git add CHANGELOG.md", "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"" }, @@ -49,6 +48,7 @@ "auto-changelog": "^2.2.1", "eslint": "^7.11.0", "functions-have-names": "^1.2.1", + "has-strict-mode": "^1.0.0", "tape": "^5.0.1" }, "auto-changelog": { diff --git a/test/implementation.js b/test/implementation.js new file mode 100644 index 0000000..1b44faf --- /dev/null +++ b/test/implementation.js @@ -0,0 +1,20 @@ +'use strict'; + +var implementation = require('../implementation'); +var callBind = require('es-abstract/helpers/callBind'); +var test = require('tape'); +var hasStrictMode = require('has-strict-mode')(); +var runTests = require('./tests'); + +test('as a function', function (t) { + t.test('bad array/this value', { skip: !hasStrictMode }, function (st) { + /* eslint no-useless-call: 0 */ + st['throws'](function () { implementation.call(undefined); }, TypeError, 'undefined is not an object'); + st['throws'](function () { implementation.call(null); }, TypeError, 'null is not an object'); + st.end(); + }); + + runTests(callBind(implementation), t); + + t.end(); +});