From 9891f31a1f3e7e70813e4682a5c56c8096bcc7dc Mon Sep 17 00:00:00 2001 From: AliMD Date: Mon, 15 Jan 2018 17:59:49 +0330 Subject: [PATCH] test(logging): improve _log with single parameter with sinon.spy --- test/unit/logging.html | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/unit/logging.html b/test/unit/logging.html index a2c4ba68bc..b8c08a95a7 100644 --- a/test/unit/logging.html +++ b/test/unit/logging.html @@ -88,17 +88,16 @@ suite('_logger', () => { test('_log with single parameter', () => { const msg = 'log test'; - const logHistory = []; const orgConsole = console; + const spy = sinon.spy(); window.console = { - log: msg => { - logHistory.push(msg); - } + log: spy }; Polymer.Base._log(msg); window.console = orgConsole; - assert.equal(logHistory[0], msg); - assert.equal(logHistory.length, 1, 'console.log called more than one time'); + assert.equal(spy.callCount, 1, 'console.log called more than one time'); + assert.equal(spy.args[0].length, 1, 'console.log called with more than one argument'); + assert.equal(spy.args[0][0], msg, 'message not pass properly to log'); }); });