Skip to content

Commit 88dbaa4

Browse files
committed
added tests for webpack#123
1 parent 27f62d3 commit 88dbaa4

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

test/browsertest/lib/index.web.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,20 @@ describe("main", function() {
488488
it("should be able to pipe loaders", function() {
489489
require("testloader!../loaders/reverseloader!../resources/abc.txt").should.be.eql("cbawebpack");
490490
});
491+
it("should allow combinations of async and sync loaders", function() {
492+
require("../loaders/syncloader!./a").should.be.eql("a");
493+
require("../loaders/asyncloader!./a").should.be.eql("a");
494+
495+
require("../loaders/syncloader!../loaders/syncloader!./a").should.be.eql("a");
496+
require("../loaders/syncloader!../loaders/asyncloader!./a").should.be.eql("a");
497+
require("../loaders/asyncloader!../loaders/syncloader!./a").should.be.eql("a");
498+
require("../loaders/asyncloader!../loaders/asyncloader!./a").should.be.eql("a");
499+
500+
require("../loaders/asyncloader!../loaders/asyncloader!../loaders/asyncloader!./a").should.be.eql("a");
501+
require("../loaders/asyncloader!../loaders/syncloader!../loaders/asyncloader!./a").should.be.eql("a");
502+
require("../loaders/syncloader!../loaders/asyncloader!../loaders/syncloader!./a").should.be.eql("a");
503+
require("../loaders/syncloader!../loaders/syncloader!../loaders/syncloader!./a").should.be.eql("a");
504+
});
491505
describe("buildin", function() {
492506
it("should handle the raw loader correctly", function() {
493507
require("raw!../resources/abc.txt").should.be.eql("abc");
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = function(content) {
2+
var cb = this.async();
3+
if(!cb) throw new Error("Loader should allow async mode");
4+
if(cb !== this.callback) throw new Error("result of this.async() should be equal to this.callback");
5+
process.nextTick(function() {
6+
cb(null, content);
7+
});
8+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = function(content) {
2+
return content;
3+
};

0 commit comments

Comments
 (0)