source: Dev/trunk/src/client/dojo/tests/errors.js

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 1.7 KB
Line 
1define([
2        "../errors/create",
3        "doh"
4], function(create, doh){
5        var TestError = create("TestError", function(message, foo){
6                this.foo = foo;
7        });
8
9        var OtherError = create("OtherError", function(message, foo, bar){
10                this.bar = bar;
11        }, TestError, {
12                getBar: function(){
13                        return this.bar;
14                }
15        });
16
17        var testError = new TestError("hello", "asdf"),
18                otherError = new OtherError("goodbye", "qwerty", "blah");
19
20        doh.register("tests.errors", [
21                {
22                        name: "TestError",
23                        runTest: function(t){
24                                t.t(testError instanceof Error, "testError should be an instance of Error");
25                                t.t(testError instanceof TestError, "testError should be an instance of TestError");
26                                t.f(testError instanceof OtherError, "testError should not be an instance of OtherError");
27                                t.f("getBar" in testError, "testError should not have a 'getBar' property");
28                                t.is("hello", testError.message, "testError's message property should be 'hello'");
29                                if((new Error()).stack){
30                                        t.t(!!testError.stack, "custom error should have stack set");
31                                }
32                        }
33                },
34                {
35                        name: "OtherError",
36                        runTest: function(t){
37                                t.t(otherError instanceof Error, "otherError should be an instance of Error");
38                                t.t(otherError instanceof TestError, "otherError should be an instance of TestError");
39                                t.t(otherError instanceof OtherError, "otherError should be an instance of OtherError");
40                                t.t("getBar" in otherError, "otherError should have a 'getBar' property");
41                                t.f(otherError.hasOwnProperty("getBar"), "otherError should not have a 'getBar' own property");
42                                t.is("blah", otherError.getBar(), "otherError should return 'blah' from getBar()");
43                                t.is("goodbye", otherError.message, "otherError's message property should be 'goodbye'");
44                        }
45                }
46        ]);
47});
Note: See TracBrowser for help on using the repository browser.