Skip to content

Commit 9aaf42b

Browse files
committed
added another test case for webpack#2084
1 parent 2125e24 commit 9aaf42b

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

test/cases/parsing/issue-2084/index.js

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ it("should bind this context on require callback", function(done) {
1212
done();
1313
} catch(e) { done(e); }
1414
}.bind(this));
15-
})
15+
});
1616
});
1717

1818
it("should bind this context on require callback (loaded)", function(done) {
@@ -25,7 +25,42 @@ it("should bind this context on require callback (loaded)", function(done) {
2525
done();
2626
} catch(e) { done(e); }
2727
}.bind(this));
28-
})
28+
});
29+
});
30+
31+
it("should bind this context on require callback (foo)", function(done) {
32+
var foo = {ok: true};
33+
require([], function(load) {
34+
try {
35+
require("./file").should.be.eql("file");
36+
this.should.be.eql({ok: true});
37+
done();
38+
} catch(e) { done(e); }
39+
}.bind(foo));
40+
});
41+
42+
it("should bind this context on require callback (foo, loaded)", function(done) {
43+
var foo = {ok: true};
44+
require(["./load.js"], function(load) {
45+
try {
46+
require("./file").should.be.eql("file");
47+
load.should.be.eql("load");
48+
this.should.be.eql({ok: true});
49+
done();
50+
} catch(e) { done(e); }
51+
}.bind(foo));
52+
});
53+
54+
it("should bind this context on require callback (foo)", function(done) {
55+
runWithThis({ok: true}, function() {
56+
require([], function(load) {
57+
try {
58+
require("./file").should.be.eql("file");
59+
this.should.be.eql({ok: {ok: true}});
60+
done();
61+
} catch(e) { done(e); }
62+
}.bind({ok: this}));
63+
});
2964
});
3065

3166
it("should bind this context on require.ensure callback", function(done) {
@@ -37,7 +72,7 @@ it("should bind this context on require.ensure callback", function(done) {
3772
done();
3873
} catch(e) { done(e); }
3974
}.bind(this));
40-
})
75+
});
4176
});
4277

4378
it("should bind this context on require.ensure callback (loaded)", function(done) {
@@ -49,5 +84,5 @@ it("should bind this context on require.ensure callback (loaded)", function(done
4984
done();
5085
} catch(e) { done(e); }
5186
}.bind(this));
52-
})
87+
});
5388
});

0 commit comments

Comments
 (0)