node.js
1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
define([ "require", "doh/main" ], function(require, doh){
doh.register("tests.node", [
function testRequireBuiltIn(t){
var td = new doh.Deferred();
require(["dojo/node!util"], td.getTestCallback(function(util){
t.t("puts" in util, "this is the built in node module");
}));
return td;
},
function testRequireMissing(t){
try{
require(["dojo/node!missing"]);
}catch(e){
t.is(e.name, "Error", "plugin threw an error");
t.is(e.message, "Cannot find module 'missing'", "module is missing");
}
},
function testRequireSimpleModule(t){
var td = new doh.Deferred();
require(["dojo/node!./resources/nodemodule"], td.getTestCallback(function(nodemodule){
t.t("test" in nodemodule, "module loaded");
t.is(nodemodule.test, "value", "object has expected value");
}));
return td;
},
function testRequireRequire(t){
var td = new doh.Deferred();
require(["dojo/node!./resources/noderequire"], td.getTestCallback(function(noderequire){
t.t("test" in noderequire, "module loaded");
t.is(noderequire.test, "value", "object has expected value");
}));
return td;
},
function testRequirePackageJson(t){
var td = new doh.Deferred();
require(["dojo/node!./resources/nodemod"], td.getTestCallback(function(nodemod){
t.t("test" in nodemod, "module loaded");
t.is(nodemod.test, "value", "object has expected value");
}));
return td;
},
function testRequireCommonJSAMD(t){
var td = new doh.Deferred();
require(["dojo/node!./resources/noderequireamd"], td.getTestCallback(function(noderequireamd){
t.t(noderequireamd.nodeamd.test === "foo", "module loaded");
}));
return td;
}
]);
});