Skip to content

Commit 757c342

Browse files
BridgeARjasnell
authored andcommitted
test: fix actual and expected order
In addition use the newer common.expectsError version. PR-URL: #14881 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent 5394458 commit 757c342

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

test/parallel/test-console.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const assert = require('assert');
2626
assert.ok(process.stdout.writable);
2727
assert.ok(process.stderr.writable);
2828
// Support legacy API
29-
assert.strictEqual('number', typeof process.stdout.fd);
30-
assert.strictEqual('number', typeof process.stderr.fd);
29+
assert.strictEqual(typeof process.stdout.fd, 'number');
30+
assert.strictEqual(typeof process.stderr.fd, 'number');
3131

3232
assert.doesNotThrow(function() {
3333
process.once('warning', common.mustCall((warning) => {
@@ -123,35 +123,35 @@ const expectedStrings = [
123123
];
124124

125125
for (const expected of expectedStrings) {
126-
assert.strictEqual(`${expected}\n`, strings.shift());
127-
assert.strictEqual(`${expected}\n`, errStrings.shift());
126+
assert.strictEqual(strings.shift(), `${expected}\n`);
127+
assert.strictEqual(errStrings.shift(), `${expected}\n`);
128128
}
129129

130130
for (const expected of expectedStrings) {
131-
assert.strictEqual(`${expected}\n`, strings.shift());
132-
assert.strictEqual(`${expected}\n`, errStrings.shift());
131+
assert.strictEqual(strings.shift(), `${expected}\n`);
132+
assert.strictEqual(errStrings.shift(), `${expected}\n`);
133133
}
134134

135-
assert.strictEqual("{ foo: 'bar', inspect: [Function: inspect] }\n",
136-
strings.shift());
137-
assert.strictEqual("{ foo: 'bar', inspect: [Function: inspect] }\n",
138-
strings.shift());
135+
assert.strictEqual(strings.shift(),
136+
"{ foo: 'bar', inspect: [Function: inspect] }\n");
137+
assert.strictEqual(strings.shift(),
138+
"{ foo: 'bar', inspect: [Function: inspect] }\n");
139139
assert.ok(strings.shift().includes('foo: [Object]'));
140140
assert.strictEqual(strings.shift().includes('baz'), false);
141141
assert.ok(/^label: \d+\.\d{3}ms$/.test(strings.shift().trim()));
142142
assert.ok(/^__proto__: \d+\.\d{3}ms$/.test(strings.shift().trim()));
143143
assert.ok(/^constructor: \d+\.\d{3}ms$/.test(strings.shift().trim()));
144144
assert.ok(/^hasOwnProperty: \d+\.\d{3}ms$/.test(strings.shift().trim()));
145145

146-
assert.strictEqual('Trace: This is a {"formatted":"trace"} 10 foo',
147-
errStrings.shift().split('\n').shift());
146+
assert.strictEqual(errStrings.shift().split('\n').shift(),
147+
'Trace: This is a {"formatted":"trace"} 10 foo');
148148

149-
assert.throws(() => {
149+
common.expectsError(() => {
150150
console.assert(false, 'should throw');
151-
}, common.expectsError({
151+
}, {
152152
code: 'ERR_ASSERTION',
153153
message: /^should throw$/
154-
}));
154+
});
155155

156156
assert.doesNotThrow(() => {
157157
console.assert(true, 'this should not throw');

0 commit comments

Comments
 (0)