Skip to content

Commit

Permalink
add test cases for webpack#3235
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Nov 16, 2016
1 parent a58ce33 commit e4dfd20
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 15 additions & 1 deletion test/configCases/plugins/define-plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ it("should define OBJECT.SUB.CODE", function() {
sub.CODE.should.be.eql(3);
}(OBJECT.SUB));
});
it("should define OBJECT.SUB.STRING", function() {
(typeof OBJECT.SUB.STRING).should.be.eql("string");
OBJECT.SUB.STRING.should.be.eql("string");
if(OBJECT.SUB.STRING !== "string") require("fail");
if(typeof OBJECT.SUB.STRING !== "string") require("fail");

(function(sub) {
// should not crash
sub.STRING.should.be.eql("string");
}(OBJECT.SUB));
});
it("should define process.env.DEFINED_NESTED_KEY", function() {
(process.env.DEFINED_NESTED_KEY).should.be.eql(5);
(typeof process.env.DEFINED_NESTED_KEY).should.be.eql("number");
Expand All @@ -61,4 +72,7 @@ it("should define process.env.DEFINED_NESTED_KEY", function() {
var x = env.DEFINED_NESTED_KEY;
x.should.be.eql(5);
}(process.env));
});
});
it("should define process.env.DEFINED_NESTED_KEY_STRING", function() {
if(process.env.DEFINED_NESTED_KEY_STRING !== "string") require("fail");
})
6 changes: 4 additions & 2 deletions test/configCases/plugins/define-plugin/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ module.exports = {
UNDEFINED: undefined,
FUNCTION: function(a) { return a + 1; },
CODE: "(1+2)",
REGEXP: /abc/i
REGEXP: /abc/i,
STRING: JSON.stringify("string")
}
},
"process.env.DEFINED_NESTED_KEY": 5
"process.env.DEFINED_NESTED_KEY": 5,
"process.env.DEFINED_NESTED_KEY_STRING": "\"string\""
})
]
}

0 comments on commit e4dfd20

Please sign in to comment.