This repository has been archived by the owner on Mar 31, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrote a test for the scripts to test if my changes broke anything.
- Loading branch information
Sven Buijsrogge
committed
Feb 4, 2016
1 parent
589f56c
commit 7881b51
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
}); | ||
}; |