Skip to content

Commit

Permalink
Merge pull request #63 from fabien-d/unitTests
Browse files Browse the repository at this point in the history
added log/extend tests
  • Loading branch information
fabien-d committed Dec 16, 2012
2 parents 95f990b + 265caec commit a33f479
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 5 deletions.
6 changes: 5 additions & 1 deletion lib/alertify.js
Expand Up @@ -286,7 +286,11 @@
* @return {Function}
*/
extend : function (type) {
return function (message, wait) { this.log(message, type, wait); };
if (typeof type !== "string") throw new Error("extend method must have exactly one paramter");
return function (message, wait) {
this.log(message, type, wait);
return this;
};
},

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/alertify.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/alertify.js
Expand Up @@ -274,7 +274,11 @@
* @return {Function}
*/
extend : function (type) {
return function (message, wait) { this.log(message, type, wait); };
if (typeof type !== "string") throw new Error("extend method must have exactly one paramter");
return function (message, wait) {
this.log(message, type, wait);
return this;
};
},

/**
Expand Down
1 change: 1 addition & 0 deletions test/index.html
Expand Up @@ -15,5 +15,6 @@
<script src="specs/alert.test.js"></script>
<script src="specs/confirm.test.js"></script>
<script src="specs/prompt.test.js"></script>
<script src="specs/log.test.js"></script>
</body>
</html>
2 changes: 0 additions & 2 deletions test/specs/global.test.js
Expand Up @@ -16,8 +16,6 @@ test("API options", function () {
deepEqual(typeof alertify.error, "function", "error notification part of the API");
// options
deepEqual(typeof alertify.set, "function", "set method part of the API");
//deepEqual(typeof alertify.labels, "object", "labels object part of the API");
//deepEqual(typeof alertify.delay, "number", "delay value part of the API");
});

module("custom labels", {
Expand Down
21 changes: 21 additions & 0 deletions test/specs/log.test.js
@@ -0,0 +1,21 @@
module("log", {
setup : function () {
this.log = alertify.log("Test");
}
});

test("log returns alertify object", function () {
expect(1);
deepEqual(this.log, alertify, "should be equal");
});

test("extend method", function () {
expect(2);
try {
alertify.extend();
} catch (error) {
deepEqual(error.message, "extend method must have exactly one paramter", "parameter error caught");
}
alertify.custom = alertify.extend("custom");
deepEqual(alertify.custom("test"), alertify, "should be equal");
});

0 comments on commit a33f479

Please sign in to comment.