From 5044c29e6335b9ec793060694c105cd5471dce8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cezary=20Kluczy=C5=84ski?= Date: Mon, 16 Nov 2015 19:54:59 +0100 Subject: [PATCH] More tests --- src/qunit-desktop-notifications.js | 12 ++++-------- tests/functional/new.js | 15 +++++++++++++++ tests/unit/messages.js | 26 ++++++++++++++++++++++---- 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/qunit-desktop-notifications.js b/src/qunit-desktop-notifications.js index 8dc482b..3e7f902 100644 --- a/src/qunit-desktop-notifications.js +++ b/src/qunit-desktop-notifications.js @@ -208,7 +208,7 @@ QUnitDesktopNotifications.notifications = { }, log: "Assertion \"" + details.name + "\" " + ( details.result ? "passed" : "failed" ), moduleStart: "Module \"" + details.name + "\" started", - moduleStop: "Module \"" + details.name + "\" " + ( details.failed ? "failed" : "passed" ), + moduleDone: "Module \"" + details.name + "\" " + ( details.failed ? "failed" : "passed" ), testStart: "Test \"" + details.name + "\" started", testDone: "Test \"" + details.name + "\" " + ( details.failed ? "failed" : "passed" ), }[ eventName ]; @@ -222,7 +222,7 @@ QUnitDesktopNotifications.notifications = { done: "Tests are done, " + ( details.failed ? "with" : "without" ) + " errors.", log: "Assertion " + ( details.result ? "passed" : "failed" ) + ".", moduleStart: "Module started.", - moduleStop: "Module finished.", + moduleDone: "Module finished.", testStart: "Test started.", testDone: "Test finished.", }[ eventName ]; @@ -239,7 +239,7 @@ QUnitDesktopNotifications.notifications = { } /** Single assertion has "result" key set to true if assertion passed. */ - return details.result ? this.icons.tick : this.icons.error; + return details.result === true ? this.icons.tick : this.icons.error; }, icons: { /** @@ -739,12 +739,8 @@ QUnitDesktopNotifications.profiles.cancel = function () { /** Handler for saving new profile name. */ QUnitDesktopNotifications.profiles.newProfileNameHandle = function () { - if ( ! self.$newProfile ) { - return; - } - /** Remove non-ASCII characters from string, and make string lowercase. */ - var normalizedLabel = event.target.value.replace( /[^\x00-\x7F]/g, "" ).toLowerCase();; + var normalizedLabel = event.target.value.replace( /[^\x00-\x7F]/g, "" ).toLowerCase(); self.$newProfile.text = self.$newProfile.value = normalizedLabel; diff --git a/tests/functional/new.js b/tests/functional/new.js index d2322a0..fb1670f 100644 --- a/tests/functional/new.js +++ b/tests/functional/new.js @@ -49,6 +49,21 @@ define([ assert.ok( enabled ); }) .end() + /** Clear input. */ + .findByCssSelector( "input[name=\"name\"]" ) + .type( "\b\b\b\b" ) + .end() + /** Assert that "Save" button is disabled again when name is cleared. */ + .findByCssSelector( "button[action=\"save\"]" ) + .isEnabled() + .then( function ( enabled ) { + assert.notOk( enabled ); + }) + .end() + /** Revert to "Test" value. */ + .findByCssSelector( "input[name=\"name\"]" ) + .type( "Test" ) + .end() /** Find option, and assert it's label. */ .findByCssSelector( "select option[value=\"test\"]" ) .getVisibleText() diff --git a/tests/unit/messages.js b/tests/unit/messages.js index 24ddc36..e772df5 100644 --- a/tests/unit/messages.js +++ b/tests/unit/messages.js @@ -17,6 +17,8 @@ define([ assert.equal( n.getMessageBody( "begin", { totalTests: 0 } ), "No tests are scheduled." ); assert.equal( n.getMessageBody( "begin", { totalTests: 1 } ), "1 test is scheduled." ); assert.equal( n.getMessageBody( "begin", { totalTests: 2 } ), "2 tests are scheduled." ); + + assert.equal( n.getMessageIcon( "begin", {} ), n.icons.info ); }, done: function () { assert.equal( n.getMessageTitle( "done", { failed: 0 } ), "Tests are done, without errors." ); @@ -34,6 +36,9 @@ define([ "2 tests executed, 1 passed, 1 failed." ); assert.equal( n.getMessageBody( "done", { total: 2, passed: 0, failed: 2 } ), "2 tests executed, 0 passed, 2 failed." ); + + assert.equal( n.getMessageIcon( "done", { failed: 0 } ), n.icons.tick ); + assert.equal( n.getMessageIcon( "done", { failed: 1 } ), n.icons.error ); }, log: function () { assert.equal( n.getMessageTitle( "log", { result: true } ), "Assertion passed." ); @@ -41,28 +46,41 @@ define([ assert.equal( n.getMessageBody( "log", { name: "Test", result: true } ), "Assertion \"Test\" passed" ); assert.equal( n.getMessageBody( "log", { name: "Test", result: true } ), "Assertion \"Test\" passed" ); + + assert.equal( n.getMessageIcon( "log", { result: true } ), n.icons.tick ); + assert.equal( n.getMessageIcon( "log", { result: false } ), n.icons.error ); }, moduleStart: function () { assert.equal( n.getMessageTitle( "moduleStart", { name: "Tests" } ), "Module started." ); assert.equal( n.getMessageBody( "moduleStart", { name: "Tests" } ), "Module \"Tests\" started" ); + + assert.equal( n.getMessageIcon( "moduleStart", {} ), n.icons.info ); }, - moduleStop: function () { - assert.equal( n.getMessageTitle( "moduleStop", { name: "Tests" } ), "Module finished." ); + moduleDone: function () { + assert.equal( n.getMessageTitle( "moduleDone", { name: "Tests" } ), "Module finished." ); - assert.equal( n.getMessageBody( "moduleStop", { name: "Tests", failed: 0 } ), "Module \"Tests\" passed" ); - assert.equal( n.getMessageBody( "moduleStop", { name: "Tests", failed: 1 } ), "Module \"Tests\" failed" ); + assert.equal( n.getMessageBody( "moduleDone", { name: "Tests", failed: 0 } ), "Module \"Tests\" passed" ); + assert.equal( n.getMessageBody( "moduleDone", { name: "Tests", failed: 1 } ), "Module \"Tests\" failed" ); + + assert.equal( n.getMessageIcon( "moduleDone", { failed: 0 } ), n.icons.tick ); + assert.equal( n.getMessageIcon( "moduleDone", { failed: 1 } ), n.icons.error ); }, testStart: function () { assert.equal( n.getMessageTitle( "testStart", { name: "Tests" } ), "Test started." ); assert.equal( n.getMessageBody( "testStart", { name: "Tests" } ), "Test \"Tests\" started" ); + + assert.equal( n.getMessageIcon( "testStart", {} ), n.icons.info ); }, testDone: function () { assert.equal( n.getMessageTitle( "testDone", { name: "Tests" } ), "Test finished." ); assert.equal( n.getMessageBody( "testDone", { name: "Tests", failed: 0 } ), "Test \"Tests\" passed" ); assert.equal( n.getMessageBody( "testDone", { name: "Tests", failed: 1 } ), "Test \"Tests\" failed" ); + + assert.equal( n.getMessageIcon( "testDone", { failed: 0 } ), n.icons.tick ); + assert.equal( n.getMessageIcon( "testDone", { failed: 1 } ), n.icons.error ); } }); });