Skip to content

Commit 233baaf

Browse files
committed
refactor: modernize test codebase
1 parent 269535d commit 233baaf

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

test/test.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
'use strict';
22

3-
const child = require('child_process');
4-
const fs = require('fs');
5-
const path = require('path');
3+
const { spawn } = require('child_process');
4+
const { readFileSync } = require('fs');
5+
const { join, resolve } = require('path');
66
const concat = require('concat-stream');
7-
const assert = require('assert');
8-
const unassertCommand = path.join(__dirname, '..', 'bin', 'cmd.js');
7+
const assert = require('assert').strict;
8+
const unassertCommand = join(__dirname, '..', 'bin', 'cmd.js');
99

1010
function testUnassertCommand (fixtureName) {
11-
const fixtureFilepath = path.resolve(__dirname, 'fixtures', fixtureName, 'fixture.js');
12-
const expectedFilepath = path.resolve(__dirname, 'fixtures', fixtureName, 'expected.js');
13-
const input = fs.readFileSync(fixtureFilepath, 'utf8');
14-
const expected = fs.readFileSync(expectedFilepath, 'utf8');
11+
const fixtureFilepath = resolve(__dirname, 'fixtures', fixtureName, 'fixture.js');
12+
const expectedFilepath = resolve(__dirname, 'fixtures', fixtureName, 'expected.js');
13+
const input = readFileSync(fixtureFilepath, 'utf8');
14+
const expected = readFileSync(expectedFilepath, 'utf8');
1515
function assertOutputMatches (proc, done) {
16-
proc.stdout.pipe(concat(function (output) {
16+
proc.stdout.pipe(concat((output) => {
1717
assert.equal(output.toString('utf8'), expected);
1818
done();
1919
}));
2020
}
21-
describe(fixtureName, function () {
22-
it('open file when filepath is specified', function (done) {
23-
const proc = child.spawn(unassertCommand, [fixtureFilepath]);
21+
describe(fixtureName, () => {
22+
it('open file when filepath is specified', (done) => {
23+
const proc = spawn(unassertCommand, [fixtureFilepath]);
2424
assertOutputMatches(proc, done);
2525
});
26-
it('read from stdin when filepath is not specified', function (done) {
27-
const proc = child.spawn(unassertCommand);
26+
it('read from stdin when filepath is not specified', (done) => {
27+
const proc = spawn(unassertCommand);
2828
assertOutputMatches(proc, done);
2929
proc.stdin.end(input);
3030
});
31-
it('read from stdin when filepath is "-"', function (done) {
32-
const proc = child.spawn(unassertCommand, ['-']);
31+
it('read from stdin when filepath is "-"', (done) => {
32+
const proc = spawn(unassertCommand, ['-']);
3333
assertOutputMatches(proc, done);
3434
proc.stdin.end(input);
3535
});
3636
});
3737
}
3838

39-
describe('unassert-cli', function () {
39+
describe('unassert-cli', () => {
4040
testUnassertCommand('func');
4141
testUnassertCommand('commonjs');
4242
testUnassertCommand('commonjs_singlevar');

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy