Skip to content

Commit

Permalink
Verifying that #144 is solved (closes #144)
Browse files Browse the repository at this point in the history
  • Loading branch information
joakimbeng committed Mar 18, 2016
1 parent 852fe9d commit 19eb92c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/inject/expected/issue144.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//- inject:js
script(src="/fixtures/lib.js")
//- endinject
//- inject:jsx
script(type="text/jsx", src="/fixtures/component.jsx")
//- endinject
5 changes: 5 additions & 0 deletions src/inject/fixtures/issue144.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//- inject:js
//- endinject
//- inject:jsx
//- endinject
24 changes: 18 additions & 6 deletions src/inject/inject_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,18 @@ describe('gulp-inject', function () {
streamShouldContain(stream, ['defaults.jade'], done);
});

it('should be able to inject jsx into jade files (Issue #144)', function (done) {
var target = src(['issue144.jade'], {read: true});
var sources = src([
'lib.js',
'component.jsx'
]);

var stream = target.pipe(inject(sources));

streamShouldContain(stream, ['issue144.jade'], done);
});

it('should use special default tags when injecting into slm files', function (done) {
var target = src(['template.slm'], {read: true});
var sources = src([
Expand Down Expand Up @@ -428,7 +440,7 @@ describe('gulp-inject', function () {
'lib.jsx'
]);

var stream = target.pipe(inject(sources,{removeTags:true}));
var stream = target.pipe(inject(sources, {removeTags: true}));

streamShouldContain(stream, ['removeTags.html'], done);
});
Expand Down Expand Up @@ -555,18 +567,18 @@ describe('gulp-inject', function () {
});
});

function src (files, opt) {
function src(files, opt) {
opt = opt || {};
var stream = es.readArray(files.map(function (file) {
return fixture(file, opt.read);
}));
return stream;
}

function streamShouldContain (stream, files, done) {
function streamShouldContain(stream, files, done) {
var received = 0;

stream.on('error', function(err) {
stream.on('error', function (err) {
should.exist(err);
done(err);
});
Expand All @@ -591,7 +603,7 @@ function streamShouldContain (stream, files, done) {
});
}

function expectedFile (file) {
function expectedFile(file) {
var filepath = path.resolve(__dirname, 'expected', file);
return new gutil.File({
path: filepath,
Expand All @@ -601,7 +613,7 @@ function expectedFile (file) {
});
}

function fixture (file, read) {
function fixture(file, read) {
var filepath = path.resolve(__dirname, 'fixtures', file);
return new gutil.File({
path: filepath,
Expand Down
4 changes: 4 additions & 0 deletions src/transform/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ transform.jade.js = function (filepath) {
return 'script(src="' + filepath + '")';
};

transform.jade.jsx = function (filepath) {
return 'script(type="text/jsx", src="' + filepath + '")';
};

transform.jade.jade = function (filepath) {
return 'include ' + filepath;
};
Expand Down

0 comments on commit 19eb92c

Please sign in to comment.