4 June, 2014
0 Comments
1 category
Just an example HTML page for reporting Jasmine 2.0 tests.
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Jasmine 2.0 example page.</title> <link href="jasmine.css" rel="stylesheet" /> <script src="jasmine.js"></script> <script src="jasmine-html.js"></script> <script src="boot.js"></script> </head> <body> <script> // This is the function we will test. function addOne(num) { if (typeof num == "number") { return num + 1 } else { return "not a number" } } // These are the tests. describe("addOne", function () { it("should be a function", function () { expect(typeof addOne).toEqual('function'); }); it("should be add one to an integer argument", function () { expect(addOne(1)).toEqual(2); }); describe("when argument is not a number", function () { it("should return 'not a number' when argument is String", function () { expect(addOne("this is a string")).toEqual("not a number"); }); }) }) </script> </body> </html>
Tags: JasmineJavascript
Category: Uncategorized