Skip to content

Commit d43fdc0

Browse files
committed
tests (currently failing, and work-in-progress)
1 parent a027d0e commit d43fdc0

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed

lib/loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = function(content, map) {
1818
var camelCaseKeys = query.camelCase || query.camelcase;
1919
var resolve = createResolver(query.alias);
2020

21-
var givenExternals = query.externals || {};
21+
var givenExternals = query.externals || (this.externals || {});
2222
var externals = {};
2323
if (Array.isArray(givenExternals)) {
2424
givenExternals.forEach(function (external) {

test/externalsTest.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*globals describe */
2+
3+
var test = require("./helpers").test;
4+
5+
function testLocal(name, input, result, localsResult, query, modules) {
6+
result.locals = localsResult;
7+
test(name, input, result, query, modules);
8+
}
9+
10+
describe("externals", function() {
11+
before(function () {
12+
global.External = {
13+
External: {
14+
c2: "imported-c2",
15+
c4: "imported-c4"
16+
}
17+
};
18+
});
19+
20+
testLocal(
21+
// name
22+
"composes class from external module",
23+
24+
// input
25+
[
26+
":local(.c1) { composes: c2 from \"external\"; b: 1; }",
27+
":local(.c3) { composes: c1; b: 3; }",
28+
":local(.c5) { composes: c2 c4 from \"external\"; b: 5; }"
29+
].join("\n"),
30+
31+
// result
32+
[
33+
[
34+
2,
35+
".test{c: d}",
36+
""
37+
],
38+
[
39+
1,
40+
[
41+
"._c1 { b: 1; }",
42+
"._c3 { b: 3; }",
43+
"._c5 { b: 5; }"
44+
].join("\n"), ""]
45+
],
46+
47+
// localsResult
48+
{
49+
c1: "_c1 imported-c2",
50+
c3: "_c3 _c1 imported-c2",
51+
c5: "_c5 imported-c2 imported-c4"
52+
},
53+
54+
// query
55+
{
56+
localIdentName: '[name]__[local]___[hash:base64:5]',
57+
externals: {
58+
external: 'External'
59+
}
60+
},
61+
62+
// modules
63+
{}
64+
);
65+
66+
after(function () {
67+
delete global.External;
68+
})
69+
});

0 commit comments

Comments
 (0)