0 Comments

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>

image

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts

Two nice articles on RxJS

The first article is a nice introduction. https://www.barbarianmeetscoding.com/blog/2016/04/11/getting-started-with-rx-dot-js/ and the…