From 9ccad5a4052d4e2bf79603ac7c82411536486248 Mon Sep 17 00:00:00 2001 From: Stephen Niedzielski Date: Tue, 24 Apr 2018 17:00:10 -0500 Subject: [PATCH] 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 --- tests/qunit/skins.minerva.scripts/test_DownloadIcon.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/qunit/skins.minerva.scripts/test_DownloadIcon.js b/tests/qunit/skins.minerva.scripts/test_DownloadIcon.js index 4d00a6b..b7a086a 100644 --- a/tests/qunit/skins.minerva.scripts/test_DownloadIcon.js +++ b/tests/qunit/skins.minerva.scripts/test_DownloadIcon.js @@ -24,7 +24,7 @@ icon.onClick(); d.then( function () { - assert.ok( spy.calledOnce, 'Print occurred.' ); + assert.strictEqual( spy.callCount, 1, 'Print occurred.' ); } ); return d; @@ -43,7 +43,7 @@ icon.onClick(); d.then( function () { - assert.ok( spy.calledOnce, + assert.strictEqual( spy.callCount, 1, 'Print was called once despite loadImagesList resolving after MAX_PRINT_TIMEOUT' ); } ); @@ -64,7 +64,7 @@ icon.onClick(); icon.onClick(); d.then( function () { - assert.ok( spy.calledOnce, + assert.strictEqual( spy.callCount, 1, 'Print was called once despite multiple clicks' ); } );