Skip to content

Commit

Permalink
cleanup test fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Dec 24, 2015
1 parent 4353d06 commit 83b189b
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 41 deletions.
3 changes: 1 addition & 2 deletions test/fixture/async-await.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
const test = require('../../');
import test from '../../';

test('async function', async function (t) {
t.plan(1);
Expand Down
2 changes: 1 addition & 1 deletion test/fixture/circular-reference-on-assertion.js
Original file line number Diff line number Diff line change
@@ -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']);
});
2 changes: 1 addition & 1 deletion test/fixture/destructuring-public-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
3 changes: 1 addition & 2 deletions test/fixture/generators.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
const test = require('../../');
import test from '../../';

test('generator function', function * (t) {
t.plan(1);
Expand Down
5 changes: 2 additions & 3 deletions test/fixture/hooks-failing.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
5 changes: 2 additions & 3 deletions test/fixture/hooks-passing.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const test = require('../../');
import test from '../../';

test.before(pass);
test.beforeEach(pass);
test.after(pass);
test.afterEach(pass);
test(pass);

function pass(t) {
}
function pass() {}
1 change: 0 additions & 1 deletion test/fixture/ignored-dirs/fixtures/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ import test from '../../../../';

test(t => {
t.pass();
t.end();
});
1 change: 0 additions & 1 deletion test/fixture/ignored-dirs/helpers/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ import test from '../../../../';

test(t => {
t.pass();
t.end();
});
23 changes: 12 additions & 11 deletions test/fixture/long-running.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
'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},
ava: true
});
}, {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);
});
4 changes: 2 additions & 2 deletions test/fixture/loud-rejection.js
Original file line number Diff line number Diff line change
@@ -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();
});
});
2 changes: 1 addition & 1 deletion test/fixture/one-pass-one-fail.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const test = require('../../');
import test from '../../';

test('this is a passing test', t => {
t.ok(true);
Expand Down
3 changes: 1 addition & 2 deletions test/fixture/process-cwd.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
const test = require('../../');
import test from '../../';

test(t => {
t.is(process.cwd(), __dirname);
Expand Down
2 changes: 1 addition & 1 deletion test/fixture/source-map-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down
2 changes: 1 addition & 1 deletion test/fixture/source-map-inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down
6 changes: 3 additions & 3 deletions test/fixture/throw-anonymous-function.js
Original file line number Diff line number Diff line change
@@ -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 () => {};
});
});
6 changes: 3 additions & 3 deletions test/fixture/throw-named-function.js
Original file line number Diff line number Diff line change
@@ -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;
});
});
6 changes: 3 additions & 3 deletions test/fixture/uncaught-exception.js
Original file line number Diff line number Diff line change
@@ -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!`);
});
});

0 comments on commit 83b189b

Please sign in to comment.