Skip to content

Commit

Permalink
Consolidate label conversion tests + add timeLog
Browse files Browse the repository at this point in the history
  • Loading branch information
domfarolino committed Jun 7, 2018
1 parent 5133c54 commit 70c9654
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 101 deletions.
55 changes: 0 additions & 55 deletions console/console-counting-label-conversion.any.js

This file was deleted.

37 changes: 37 additions & 0 deletions console/console-label-conversion.any.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"use strict";
// https://console.spec.whatwg/org/#counting
// https://console.spec.whatwg/org/#timing

// toString() console label test strings
const toStringAssertionEnding = 'must call toString() on label when label is an object';
const toStringTestNameEnding = 'label gets converted to string via label.toString() when label is an object';

// toString error re-throwing console test strings
const toStringRethrowAssertionEnding = 'must re-throw any exceptions thrown by label.toString() conversion';
const toStringRethrowTestNameEnding = 'throws exceptions generated by erroneous label.toString() conversion';

const methods = ['count', 'countReset', 'time', 'timeLog', 'timeEnd'];

for (const method of methods) {
test(() => {
let labelToStringCalled = false;

console[method]({
toString() {
labelToStringCalled = true;
}
});

assert_true(labelToStringCalled, `${method}() ${toStringAssertionEnding}`);
}, `console.${method}()'s ${toStringTestNameEnding}`);

test(() => {
assert_throws({name: 'Error'}, () => {
console[method]({
toString() {
throw new Error('conversion error');
}
});
}, `${method} ${toStringRethrowAssertionEnding}`);
}, `console.${method}() ${toStringRethrowTestNameEnding}`);
}
46 changes: 0 additions & 46 deletions console/console-time-label-conversion.any.js

This file was deleted.

0 comments on commit 70c9654

Please sign in to comment.