Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test coverage #7

Merged
merged 2 commits into from
Oct 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
coverage
node_modules
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var gutil = require( 'gulp-util' );
var through = require( 'through2' );

function _normalizePath ( input ) {
input = input || '/';
var len = input.length;
var end = input[ len - 1 ];
return input + (end === '/' ? '' : '/');
Expand Down
44 changes: 43 additions & 1 deletion test/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ var gutil = require( 'gulp-util' );
var include = require( '../index' );
var path = require( 'path' );

var through = require( 'through2' );

var JS_INCLUDE = '<script src="include/path/javascript.js"></script>';
var CSS_INCLUDE = '<link href="include/path/style.css" rel="stylesheet">';
var CSS_INCLUDE_XHTML = '<link href="include/path/style.css" rel="stylesheet" />';
Expand Down Expand Up @@ -71,6 +73,46 @@ describe('File Generation', function () {
}));
});

it('should pass through `null` files', function ( done ) {
var stream = include();

stream.on( 'data', function ( file ) {
expect( file.contents ).to.equal( null );
done();
});

stream.write( new gutil.File({
path: 'style.css',
contents: null
}));
});

it('should throw an error when it sees a stream', function () {
var stream = include();

function useStream () {
stream.write( new gutil.File({
path: 'blah.css',
contents: through()
}));
}

expect( useStream ).to.throw();
});

it('should thrown an error when it sees a non-JS or CSS file', function () {
var stream = include();

function invalidFile () {
stream.write( new gutil.File({
path: 'image.jpg',
contents: new Buffer( '' )
}));
}

expect( invalidFile ).to.throw();
});

});

describe('Include Pathing', function () {
Expand Down Expand Up @@ -164,4 +206,4 @@ describe('Output Destinations', function () {
}));
});

});
});