Skip to content

Commit

Permalink
Test layers browser with grunt jasmine (#329)
Browse files Browse the repository at this point in the history
* Set up babel and spec file

* Update travis config

* Update register task for babel

* Update travis.yml scripts

* Update node version and scripts

* Write basic tests

* Set up grunt copy

* Add json file to fixtures and add more tests
  • Loading branch information
crisner authored and jywarren committed Jan 6, 2020
1 parent b579fe8 commit 71e434e
Show file tree
Hide file tree
Showing 8 changed files with 1,871 additions and 32 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
language: node_js
node_js:
- '5'
- '10'
before_install:
- npm install -g grunt-cli
before_script:
- grunt build
script: grunt jasmine
script:
- grunt transpile
- grunt jasmine
38 changes: 36 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,43 @@ module.exports = function(grunt) {
dist: {
src: ['node_modules/jquery/dist/jquery.min.js', 'node_modules/leaflet/dist/leaflet.js', 'src/leafletEnvironmentalLayers.js', 'src/util/*.js'],
dest: 'dist/LeafletEnvironmentalLayers.js'
},
babel: {
files: {
"dist/util/layersBrowser.js": "dist/util/layersBrowser_babel.js"
}
}
},

copy: {
dist: {
files: [
{src: 'spec/javascripts/fixtures/layerData.json', dest: 'dist/layerData.json'},
],
},
},

babel: {
options: {
sourceMap: true,
presets: ['@babel/preset-env'],
"plugins": [
"transform-object-rest-spread",
"transform-remove-strict-mode"
]
},
dist: {
files: {
"dist/util/layersBrowser_babel.js": "src/util/layersBrowser.js"
}
}
},

jasmine: {
src: ['dist/LeafletEnvironmentalLayers.js',
'src/util/embedControl.js'],
'src/util/embedControl.js',
'dist/util/layersBrowser.js'
],
options: {
specs: "spec/javascripts/*spec.js",
vendor: [
Expand Down Expand Up @@ -64,8 +95,11 @@ module.exports = function(grunt) {
*/

/* Default (development): Watch files and build on change. */
grunt.loadNpmTasks('grunt-babel');
grunt.loadNpmTasks("grunt-contrib-jasmine");
grunt.registerTask("default", ["watch", "jasmine"]);
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.registerTask("default", ["watch", "babel", "jasmine"]);
grunt.registerTask('transpile', [ 'copy', 'babel', 'browserify:babel' ]);
grunt.registerTask("test", ["jshint", "jasmine"]);
grunt.registerTask('build', [
'browserify:dist'
Expand Down
4 changes: 4 additions & 0 deletions _SpecRunner.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

<script src="src/util/embedControl.js"></script>

<script src="dist/util/layersBrowser.js"></script>

<script src="spec/javascripts/embedControl.spec.js"></script>

<script src="spec/javascripts/indigenousLanguagesLayers_spec.js"></script>
Expand All @@ -44,6 +46,8 @@

<script src="spec/javascripts/indigenousTreatiesLayers_spec.js"></script>

<script src="spec/javascripts/layersBrowser.spec.js"></script>

<script src="spec/javascripts/mapknitterLayer_spec.js"></script>

<script src="spec/javascripts/PLpeopleLayerTest_spec.js"></script>
Expand Down
Loading

0 comments on commit 71e434e

Please sign in to comment.