Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

Commit

Permalink
Wrote a test for the scripts to test if my changes broke anything.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Buijsrogge committed Feb 4, 2016
1 parent 589f56c commit 7881b51
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions elixir-test-app/test/scripts.js
@@ -0,0 +1,63 @@
var fs = require('fs');
var gulp = require('gulp');
var remove = require('rimraf');
var Elixir = require('laravel-elixir');


describe('Scripts Task', function() {

beforeEach(() => {
Elixir.tasks = Elixir.config.tasks = [];
});

it('merges scripts together', function(done) {
Elixir(mix => mix.scripts(['lib1.js', 'lib2.js']));

runGulp(() => {
shouldExist('public/js/all.js');

done();
});
});

it('merges to any file the user wishes', function(done) {
Elixir(mix => mix.scripts(['lib1.js', 'lib2.js'], './public/js/merged.js'));

runGulp(() => {
shouldExist('public/js/merged.js');

done();
});
});

it('applies a custom base directory', function(done) {
Elixir(mix => {
// We'll copy files over to a custom directory to test this.
mix.copy('./resources/assets/js', './resources/assets/scripts');

mix.scripts(['lib1.js', 'lib2.js'], null, './resources/assets/scripts');
});

runGulp(() => {
shouldExist('public/js/all.js');

done();
});
});

});


var shouldExist = (file) => {
return fs.existsSync(file).should.be.true;
};


var runGulp = assertions => {
gulp.start('default', () => {
assertions();

remove.sync('./public/js');
remove.sync('./resources/assets/scripts');
});
};

0 comments on commit 7881b51

Please sign in to comment.