/
export_standalone_test.js
93 lines (84 loc) · 1.97 KB
/
export_standalone_test.js
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
var assert = require("assert");
var stealExport = require("../lib/build/export");
var rmdir = require("rimraf");
var testHelpers = require("./helpers");
var find = testHelpers.find;
var open = testHelpers.open;
describe("+standalone", function(){
it("Works with exporting a module from a dependency", function(done){
this.timeout(10000);
stealExport({
steal: {
config: __dirname+"/exports_basics/package.json!npm"
},
options: { quiet: true },
"outputs": {
"+standalone": {
exports: {
"foo": "FOO.foo"
},
dest: __dirname + "/exports_basics/out.js"
}
}
})
.then(function() {
open("test/exports_basics/global.html",
function(browser, close) {
find(browser,"FOO", function(foo){
assert.equal(foo.foo.bar.name, "bar", "it worked");
close();
}, close);
}, done);
}, done);
});
it("Works when using dest as a function", function(done){
this.timeout(10000);
stealExport({
steal: {
config: __dirname + "/exports_basics/package.json!npm"
},
options: { quiet: true },
outputs: {
"+standalone": {
exports: { "foo": "FOO.foo" },
dest: function(){
return __dirname + "/exports_basics/out.js"
}
}
}
})
.then(function(){
open("test/exports_basics/global.html",
function(browser, close) {
find(browser,"FOO", function(foo){
assert.equal(foo.foo.bar.name, "bar", "it worked");
close();
}, close);
}, done);
});
});
it("Can be used for node.js projects", function(done){
this.timeout(10000);
var outPath = __dirname + "/exports_basics/out.js";
stealExport({
steal: {
config: __dirname + "/exports_basics/package.json!npm"
},
options: { quiet: true },
outputs: {
"+standalone": {
exports: { "foo": "FOO.foo" },
dest: function(){
return outPath;
}
}
}
})
.then(function(){
require(outPath);
assert.ok(true, "Was able to require the created module");
done();
})
.catch(done);
});
});