Hygiene: replace calledOnce / Twice w/ callCount
Replace all test assertions for calledOnce / Twice with callCount. assert.ok( calledOnce / Twice ) only lets the dev know that a test fails. assert.strictEqual( callCount, EXPECTATION ) starts the debugging process when it fails since it provides the difference in the failure output. strictEqual() was deliberately used since it's a saner default and the codebase already favors === equivalency checks. find tests -name \*.js| xargs -rd\\n sed -ri ' s%ok\(([^,]+)calledOnce%strictEqual(\1callCount, 1%g; s%ok\(([^,]+)calledTwice%strictEqual(\1callCount, 2%g; ' Change-Id: I5c4c595c4520cecfad46d652f639a63a1c2c00b4
This commit is contained in:
parent
dcc69d816f
commit
9ccad5a405
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
icon.onClick();
|
icon.onClick();
|
||||||
d.then( function () {
|
d.then( function () {
|
||||||
assert.ok( spy.calledOnce, 'Print occurred.' );
|
assert.strictEqual( spy.callCount, 1, 'Print occurred.' );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
icon.onClick();
|
icon.onClick();
|
||||||
d.then( function () {
|
d.then( function () {
|
||||||
assert.ok( spy.calledOnce,
|
assert.strictEqual( spy.callCount, 1,
|
||||||
'Print was called once despite loadImagesList resolving after MAX_PRINT_TIMEOUT' );
|
'Print was called once despite loadImagesList resolving after MAX_PRINT_TIMEOUT' );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
icon.onClick();
|
icon.onClick();
|
||||||
icon.onClick();
|
icon.onClick();
|
||||||
d.then( function () {
|
d.then( function () {
|
||||||
assert.ok( spy.calledOnce,
|
assert.strictEqual( spy.callCount, 1,
|
||||||
'Print was called once despite multiple clicks' );
|
'Print was called once despite multiple clicks' );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue