Skip to content

Commit

Permalink
chore(test): update away from deprecated tap methods
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Sep 13, 2021
1 parent 14d6a22 commit 4d51cb1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 33 deletions.
2 changes: 1 addition & 1 deletion test/internals.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ t.test('removes namespaced internal modules', t => {
'Object.<anonymous> (node_modules/append-transform/index.js:62:4)',
])
t.plan(1);
t.is(stackUtils.clean(stack), expectedStack);
t.equal(stackUtils.clean(stack), expectedStack);
});
8 changes: 4 additions & 4 deletions test/long-stack-traces.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ t.test('indents lines after first "From previous event:"', t => {
' Object.<anonymous> (produce-long-stack-traces.js:6:36)'
]);

t.is(cleanedStack, expected);
t.equal(cleanedStack, expected);
});
});

Expand All @@ -54,7 +54,7 @@ t.test('removes empty "From previous event:" sections from the bottom', t => {
' outer (produce-long-stack-traces.js:40:28)'
]);

t.is(cleanedStack, expected);
t.equal(cleanedStack, expected);
});
});

Expand All @@ -74,7 +74,7 @@ t.test('removes empty "From previous event:" sections from the top', t => {
' Object.<anonymous> (produce-long-stack-traces.js:30:40)'
]);

t.is(cleanedStack, expected);
t.equal(cleanedStack, expected);
});
});

Expand Down Expand Up @@ -124,7 +124,7 @@ t.test('removes empty "Caused by:" sections from the bottom', t => {
' moreNested (nested-errors.js:15:6)'
]);

t.is(cleanedStack, expected);
t.equal(cleanedStack, expected);
t.end();
});
});
Expand Down
54 changes: 26 additions & 28 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const WindowsStack1 = utils.join(windowsStack1(), internalStack());
const version = process.version.slice(1).split('.').map(Number);

t.test('must be called with new', t => {
t.is(typeof StackUtils, 'function');
t.equal(typeof StackUtils, 'function');
const stackUtils = StackUtils;
t.throws(() => stackUtils());
t.end();
Expand Down Expand Up @@ -44,15 +44,15 @@ t.test('clean: truncates cwd', t => {
const expected = utils.join(expectedArray);

let stack = new StackUtils({cwd: '/user/dev/project', internals: []});
t.is(stack.clean(LinuxStack1), expected, 'accepts a linux string');
t.is(stack.clean(LinuxStack1.split('\n')), expected, 'accepts an array');
t.is(stack.clean(LinuxStack1.split('\n').slice(1)), expected, 'slices off the message line');
t.equal(stack.clean(LinuxStack1), expected, 'accepts a linux string');
t.equal(stack.clean(LinuxStack1.split('\n')), expected, 'accepts an array');
t.equal(stack.clean(LinuxStack1.split('\n').slice(1)), expected, 'slices off the message line');

stack = new StackUtils({cwd: 'Z:\\user\\dev\\project', internals: []});
t.is(stack.clean(WindowsStack1), expected, 'accepts a windows string');
t.equal(stack.clean(WindowsStack1), expected, 'accepts a windows string');

const expectIndented = utils.join(expectedArray.map(a => ' ' + a));
t.is(stack.clean(WindowsStack1, 4), expectIndented, 'indentation');
t.equal(stack.clean(WindowsStack1, 4), expectIndented, 'indentation');

t.end();
});
Expand All @@ -65,16 +65,16 @@ t.test('clean: eliminates internals', t => {
'bar (project/bar.js:4:2)',
'Object.<anonymous> (project/bar.js:7:1)'
]);
t.is(stack.clean(LinuxStack1), expected);
t.equal(stack.clean(LinuxStack1), expected);

stack = new StackUtils({cwd: 'Z:\\user\\dev'});
t.is(stack.clean(WindowsStack1), expected);
t.equal(stack.clean(WindowsStack1), expected);
t.end();
});

t.test('clean: returns null if it is all internals', t => {
const stack = new StackUtils();
t.is(stack.clean(utils.join(internalStack())), '');
t.equal(stack.clean(utils.join(internalStack())), '');
t.end();
});

Expand All @@ -83,7 +83,7 @@ t.test('captureString: two redirects', t => {
const capture = new CaptureFixture(stack);

const capturedString = capture.redirect1('redirect2', 'call', 'captureString');
t.is(capturedString, utils.join([
t.equal(capturedString, utils.join([
'CaptureFixture.call (capture-fixture.js:47:28)',
'CaptureFixture.redirect2 (capture-fixture.js:13:24)',
'CaptureFixture.redirect1 (capture-fixture.js:9:24)'
Expand All @@ -96,7 +96,7 @@ t.test('captureString: with startStack function', t => {
const capture = new CaptureFixture(stack);

const capturedString = capture.redirect1('redirect2', 'call', 'captureString', capture.call);
t.is(capturedString, utils.join([
t.equal(capturedString, utils.join([
'CaptureFixture.redirect2 (capture-fixture.js:13:24)',
'CaptureFixture.redirect1 (capture-fixture.js:9:24)'
]));
Expand All @@ -108,7 +108,7 @@ t.test('captureString: with limit', t => {
const capture = new CaptureFixture(stack);

const capturedString = capture.redirect1('redirect2', 'call', 'captureString', 1);
t.is(capturedString, utils.join([
t.equal(capturedString, utils.join([
'CaptureFixture.call (capture-fixture.js:47:28)'
]));
t.end();
Expand All @@ -119,7 +119,7 @@ t.test('captureString: with limit and startStack', t => {
const capture = new CaptureFixture(stack);

const capturedString = capture.redirect1('redirect2', 'call', 'captureString', 1, capture.call);
t.is(capturedString, utils.join([
t.equal(capturedString, utils.join([
'CaptureFixture.redirect2 (capture-fixture.js:13:24)'
]));
t.end();
Expand All @@ -129,36 +129,36 @@ t.test('capture returns an array of call sites', t => {
const stackUtil = new StackUtils({internals: internals(), cwd: utils.fixtureDir});
const capture = new CaptureFixture(stackUtil);
const stack = capture.redirect1('call', 'capture').slice(0, 2);
t.is(stack[0].getFileName(), path.join(utils.fixtureDir, 'capture-fixture.js'));
t.is(stack[0].getFunctionName(), 'CaptureFixture.call');
t.is(stack[1].getFunctionName(), 'redirect1');
t.equal(stack[0].getFileName(), path.join(utils.fixtureDir, 'capture-fixture.js'));
t.equal(stack[0].getFunctionName(), 'CaptureFixture.call');
t.equal(stack[1].getFunctionName(), 'redirect1');
t.end();
});

t.test('capture: with limit', t => {
const stackUtil = new StackUtils({internals: internals(), cwd: utils.fixtureDir});
const capture = new CaptureFixture(stackUtil);
const stack = capture.redirect1('redirect2', 'call', 'capture', 1);
t.is(stack.length, 1);
t.is(stack[0].getFunctionName(), 'CaptureFixture.call');
t.equal(stack.length, 1);
t.equal(stack[0].getFunctionName(), 'CaptureFixture.call');
t.end();
});

t.test('capture: with stackStart function', t => {
const stackUtil = new StackUtils({internals: internals(), cwd: utils.fixtureDir});
const capture = new CaptureFixture(stackUtil);
const stack = capture.redirect1('redirect2', 'call', 'capture', capture.call);
t.true(stack.length > 1);
t.is(stack[0].getFunctionName(), 'redirect2');
t.ok(stack.length > 1);
t.equal(stack[0].getFunctionName(), 'redirect2');
t.end();
});

t.test('capture: with limit and stackStart function', t => {
const stackUtil = new StackUtils({internals: internals(), cwd: utils.fixtureDir});
const capture = new CaptureFixture(stackUtil);
const stack = capture.redirect1('redirect2', 'call', 'capture', 1, capture.call);
t.is(stack.length, 1);
t.is(stack[0].getFunctionName(), 'redirect2');
t.equal(stack.length, 1);
t.equal(stack[0].getFunctionName(), 'redirect2');
t.end();
});

Expand All @@ -174,9 +174,9 @@ t.test('capture: with wrapCallSite function', t => {
const stackUtil = new StackUtils({internals: internals(), cwd: utils.fixtureDir, wrapCallSite: wrapper});
const capture = new CaptureFixture(stackUtil);
const stack = capture.redirect1('redirect2', 'call', 'capture', 1, capture.call);
t.is(stack.length, 1);
t.is(stack[0].getFunctionName(), 'testOverrideFunctionName');
t.is(stack[0].getMethodName(), 'redirect2');
t.equal(stack.length, 1);
t.equal(stack[0].getFunctionName(), 'testOverrideFunctionName');
t.equal(stack[0].getMethodName(), 'redirect2');
t.end();
});

Expand Down Expand Up @@ -219,13 +219,11 @@ t.test('at: inside a constructor call', t => {
const at = capture.const('call', 'at', capture.call);

// TODO: File an issue - if this assert fails, the power assert diagram renderer blows up.
t.same(at, {
t.match(at, {
file: 'capture-fixture.js',
line: 20,
column: 32,
constructor: true,
type: 'Constructor',
function: 'Constructor'
});
t.end();
});
Expand Down

0 comments on commit 4d51cb1

Please sign in to comment.