Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cezarykluczynski committed Nov 16, 2015
1 parent 3534f3e commit 5044c29
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
12 changes: 4 additions & 8 deletions src/qunit-desktop-notifications.js
Expand Up @@ -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 ];
Expand All @@ -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 ];
Expand All @@ -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: {
/**
Expand Down Expand Up @@ -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;

Expand Down
15 changes: 15 additions & 0 deletions tests/functional/new.js
Expand Up @@ -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()
Expand Down
26 changes: 22 additions & 4 deletions tests/unit/messages.js
Expand Up @@ -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." );
Expand All @@ -34,35 +36,51 @@ 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." );
assert.equal( n.getMessageTitle( "log", { result: false } ), "Assertion failed." );

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 );
}
});
});

0 comments on commit 5044c29

Please sign in to comment.