From 83b189b5356b183a455c751e5a8c7f29795f8e17 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 24 Dec 2015 14:59:45 +0100 Subject: [PATCH] cleanup test fixtures --- test/fixture/async-await.js | 3 +-- .../circular-reference-on-assertion.js | 2 +- test/fixture/destructuring-public-api.js | 2 +- test/fixture/generators.js | 3 +-- test/fixture/hooks-failing.js | 5 ++-- test/fixture/hooks-passing.js | 5 ++-- test/fixture/ignored-dirs/fixtures/test.js | 1 - test/fixture/ignored-dirs/helpers/test.js | 1 - test/fixture/long-running.js | 23 ++++++++++--------- test/fixture/loud-rejection.js | 4 ++-- test/fixture/one-pass-one-fail.js | 2 +- test/fixture/process-cwd.js | 3 +-- test/fixture/source-map-file.js | 2 +- test/fixture/source-map-inline.js | 2 +- test/fixture/throw-anonymous-function.js | 6 ++--- test/fixture/throw-named-function.js | 6 ++--- test/fixture/uncaught-exception.js | 6 ++--- 17 files changed, 35 insertions(+), 41 deletions(-) diff --git a/test/fixture/async-await.js b/test/fixture/async-await.js index dc6598788..d20468abb 100644 --- a/test/fixture/async-await.js +++ b/test/fixture/async-await.js @@ -1,5 +1,4 @@ -'use strict'; -const test = require('../../'); +import test from '../../'; test('async function', async function (t) { t.plan(1); diff --git a/test/fixture/circular-reference-on-assertion.js b/test/fixture/circular-reference-on-assertion.js index 6d121635c..d9a0da855 100644 --- a/test/fixture/circular-reference-on-assertion.js +++ b/test/fixture/circular-reference-on-assertion.js @@ -1,7 +1,7 @@ import test from '../../'; test(t => { - var circular = ['a', 'b']; + const circular = ['a', 'b']; circular.push(circular); t.same([circular, 'c'], [circular, 'd']); }); diff --git a/test/fixture/destructuring-public-api.js b/test/fixture/destructuring-public-api.js index e840718bf..cb919ed0f 100644 --- a/test/fixture/destructuring-public-api.js +++ b/test/fixture/destructuring-public-api.js @@ -7,7 +7,7 @@ test.cb('callback mode', ({context: foo, ... t}) => { t.end(); }); -test.cb('callback mode', ({context: foo, end, ... t}) => { +test.cb('callback mode #2', ({context: foo, end, ... t}) => { t.is(foo, 'bar'); end(); }); diff --git a/test/fixture/generators.js b/test/fixture/generators.js index 2db911868..4ff185ecc 100644 --- a/test/fixture/generators.js +++ b/test/fixture/generators.js @@ -1,5 +1,4 @@ -'use strict'; -const test = require('../../'); +import test from '../../'; test('generator function', function * (t) { t.plan(1); diff --git a/test/fixture/hooks-failing.js b/test/fixture/hooks-failing.js index b4dc48b8a..ece3b0f01 100644 --- a/test/fixture/hooks-failing.js +++ b/test/fixture/hooks-failing.js @@ -1,10 +1,9 @@ -const test = require('../../'); +import test from '../../'; test.beforeEach(fail); test(pass); -function pass(t) { -} +function pass() {} function fail(t) { t.fail(); diff --git a/test/fixture/hooks-passing.js b/test/fixture/hooks-passing.js index 841d8fd12..afdcb27fd 100644 --- a/test/fixture/hooks-passing.js +++ b/test/fixture/hooks-passing.js @@ -1,4 +1,4 @@ -const test = require('../../'); +import test from '../../'; test.before(pass); test.beforeEach(pass); @@ -6,5 +6,4 @@ test.after(pass); test.afterEach(pass); test(pass); -function pass(t) { -} +function pass() {} diff --git a/test/fixture/ignored-dirs/fixtures/test.js b/test/fixture/ignored-dirs/fixtures/test.js index 888d29c32..33cdc7c26 100644 --- a/test/fixture/ignored-dirs/fixtures/test.js +++ b/test/fixture/ignored-dirs/fixtures/test.js @@ -2,5 +2,4 @@ import test from '../../../../'; test(t => { t.pass(); - t.end(); }); diff --git a/test/fixture/ignored-dirs/helpers/test.js b/test/fixture/ignored-dirs/helpers/test.js index 888d29c32..33cdc7c26 100644 --- a/test/fixture/ignored-dirs/helpers/test.js +++ b/test/fixture/ignored-dirs/helpers/test.js @@ -2,5 +2,4 @@ import test from '../../../../'; test(t => { t.pass(); - t.end(); }); diff --git a/test/fixture/long-running.js b/test/fixture/long-running.js index 6f68a1bc4..59c308c72 100644 --- a/test/fixture/long-running.js +++ b/test/fixture/long-running.js @@ -1,16 +1,17 @@ -'use strict'; -const test = require('../../'); -var onExit = require('signal-exit'); +import test from '../../'; +import signalExit from 'signal-exit'; -test.cb('long running', function (t) { +test.cb('long running', t => { t.plan(1); - onExit(function () { + signalExit(() => { // simulate an exit hook that lasts a short while - var start = Date.now(); - while(Date.now() - start < 2000) { - //synchronously wait for 2 seconds + const start = Date.now(); + + while (Date.now() - start < 2000) { + // synchronously wait for 2 seconds } + process.send({ name: 'cleanup-completed', data: {completed: true}, @@ -18,13 +19,13 @@ test.cb('long running', function (t) { }); }, {alwaysLast: true}); - setTimeout(function () { + setTimeout(() => { t.ok(true); t.end(); }); - setTimeout(function () { - // this would keep the process running for a long time. + setTimeout(() => { + // this would keep the process running for a long time console.log('I\'m gonna live forever!!'); }, 15000); }); diff --git a/test/fixture/loud-rejection.js b/test/fixture/loud-rejection.js index 1a49dc620..8a5fa1244 100644 --- a/test/fixture/loud-rejection.js +++ b/test/fixture/loud-rejection.js @@ -1,9 +1,9 @@ -const test = require('../../'); +import test from '../../'; test.cb('creates an unhandled rejection', t => { Promise.reject(new Error(`You can't handle this!`)); - setTimeout(function () { + setTimeout(() => { t.end(); }); }); diff --git a/test/fixture/one-pass-one-fail.js b/test/fixture/one-pass-one-fail.js index 6824e8da2..158c6a06b 100644 --- a/test/fixture/one-pass-one-fail.js +++ b/test/fixture/one-pass-one-fail.js @@ -1,4 +1,4 @@ -const test = require('../../'); +import test from '../../'; test('this is a passing test', t => { t.ok(true); diff --git a/test/fixture/process-cwd.js b/test/fixture/process-cwd.js index 6bfcda72a..b1aad6418 100644 --- a/test/fixture/process-cwd.js +++ b/test/fixture/process-cwd.js @@ -1,5 +1,4 @@ -'use strict'; -const test = require('../../'); +import test from '../../'; test(t => { t.is(process.cwd(), __dirname); diff --git a/test/fixture/source-map-file.js b/test/fixture/source-map-file.js index cd874c8e6..eded736c9 100644 --- a/test/fixture/source-map-file.js +++ b/test/fixture/source-map-file.js @@ -4,7 +4,7 @@ const test = require('../../'); // The uncaught exception is passed to the corresponding cli test. The line // numbers from the 'throws' fixture (which uses a map file), as well as the // line of the fixture.run() call, should match the source lines. -test('throw an uncaught exception', t => { +test('throw an uncaught exception', () => { setImmediate(run); }); diff --git a/test/fixture/source-map-inline.js b/test/fixture/source-map-inline.js index ad16add63..5a480c848 100644 --- a/test/fixture/source-map-inline.js +++ b/test/fixture/source-map-inline.js @@ -4,7 +4,7 @@ const test = require('../../'); // The uncaught exception is passed to the corresponding cli test. The line // numbers from the 'throws' fixture (using an inline source map), as well as // the line of the fixture.run() call, should match the source lines. -test('throw an uncaught exception', t => { +test('throw an uncaught exception', () => { setImmediate(run); }); diff --git a/test/fixture/throw-anonymous-function.js b/test/fixture/throw-anonymous-function.js index 3efd6b0f8..a553e5ae3 100644 --- a/test/fixture/throw-anonymous-function.js +++ b/test/fixture/throw-anonymous-function.js @@ -1,7 +1,7 @@ -const test = require('../../'); +import test from '../../'; -test('throw an uncaught exception', t => { +test('throw an uncaught exception', () => { setImmediate(() => { - throw function () {}; + throw () => {}; }); }); diff --git a/test/fixture/throw-named-function.js b/test/fixture/throw-named-function.js index 28ed00e3d..4963e5583 100644 --- a/test/fixture/throw-named-function.js +++ b/test/fixture/throw-named-function.js @@ -1,9 +1,9 @@ -const test = require('../../'); +import test from '../../'; function fooFn() {} -test('throw an uncaught exception', t => { +test('throw an uncaught exception', () => { setImmediate(() => { - throw fooFn + throw fooFn; }); }); diff --git a/test/fixture/uncaught-exception.js b/test/fixture/uncaught-exception.js index da5d47db9..c17afe6fc 100644 --- a/test/fixture/uncaught-exception.js +++ b/test/fixture/uncaught-exception.js @@ -1,7 +1,7 @@ -const test = require('../../'); +import test from '../../'; -test('throw an uncaught exception', t => { +test('throw an uncaught exception', () => { setImmediate(() => { - throw new Error(`Can't catch me!`) + throw new Error(`Can't catch me!`); }); });