Skip to content

Commit

Permalink
Testing updates (#742)
Browse files Browse the repository at this point in the history
* Update testing configurations

* lint test files

* Alphabetize rules
  • Loading branch information
sashadev-sky authored Sep 2, 2020
1 parent c4fd401 commit 7d51473
Show file tree
Hide file tree
Showing 16 changed files with 576 additions and 442 deletions.
7 changes: 1 addition & 6 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
node_modules
test/*
Gruntfile.js
dist
webpack.config.js
.eslintrc.js
dist/*
26 changes: 16 additions & 10 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
module.exports = {
env: {
browser: true
browser: true,
commonjs: true,
es6: true,
node: true,
},
extends: 'google',
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
SharedArrayBuffer: 'readonly',
},
parserOptions: {
ecmaVersion: 6
ecmaVersion: 6,
},
rules: {
/*
Expand All @@ -26,17 +29,20 @@ module.exports = {
*/

/* rules */
'arrow-parens': [2, 'as-needed', { 'requireForBlockBody': true }],
'block-spacing': ['error', 'always'],
'brace-style': ['off', '1tbs', { allowSingleLine: true }],
curly: ['error', 'multi-line'],
'arrow-parens': [2, 'as-needed', {requireForBlockBody: true}],
'block-spacing': [2, 'always'],
'brace-style': ['off', '1tbs', {allowSingleLine: true}],
'comma-style': [2, 'last'],
'curly': [2, 'multi-line'],
'guard-for-in': 0,
'linebreak-style': ['error', 'unix'],
'max-len': ['warn', { ignoreComments: true }],
'linebreak-style': [2, 'unix'],
'max-len': ['warn', {ignoreComments: true, ignoreStrings: true, tabWidth: 2}],
'new-cap': 0,
'no-trailing-spaces': 2,
'no-var': 0,
'prefer-const': 1,
'quotes': [2, 'single'],
'require-jsdoc': 0,
'valid-jsdoc': 0,
}
},
};
8 changes: 0 additions & 8 deletions .jshintrc

This file was deleted.

3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ We use SVG for our icon system. Please visit our wiki [SVG Icon System](https://

### Testing

[Guide](TESTING.md) on testing LDI.

[Guide](https://github.com/publiclab/Leaflet.DistortableImage/wiki/Testing) on testing LDI.

## Bug reports & troubleshooting

Expand Down
92 changes: 27 additions & 65 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,28 @@ const webpackConfig = require('./webpack.config.js');

module.exports = function(grunt) {
// load npm tasks for grunt-* libs, excluding grunt-cli
require('matchdep').filterDev('grunt-*').filter(function(pkg) {
require('matchdep').filterDev('{grunt,gruntify}-*').filter(function(pkg) {
return ['grunt-cli'].indexOf(pkg) < 0;
}).forEach(grunt.loadNpmTasks);

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

webpack: {
myConfig: webpackConfig
myConfig: webpackConfig,
},

jshint: {
options: {
node: true,
browser: true,
esversion: 6,
mocha: true,
typed: true,
bitwise: true,
curly: true,
eqeqeq: true,
latedef: true,
noarg: true,
regexp: true,
undef: true,
globals: {
L: false,
LeafletToolbar: false,
warpWebGl: false,
EXIF: false,
alert: false,

// Mocha

describe: false,
it: false,
before: false,
after: false,
beforeEach: false,
afterEach: false,
chai: false,
expect: false,
sinon: false
}
},
source: {
src: ['src/**/*.js', 'package.json']
},
grunt: {
src: ['Gruntfile.js']
}
eslint: {
src: ['src/**/*.js', 'test/**/*.js'],
},

karma: {
development: {
configFile: 'test/karma.conf.js'
configFile: 'test/karma.conf.js',
},
test: {
configFile: 'test/karma.conf.js'
}
configFile: 'test/karma.conf.js',
},
},

// Minify SVGs from svg directory, output to svg-min
Expand All @@ -73,9 +35,9 @@ module.exports = function(grunt) {
cwd: 'assets/icons/svg',
src: ['*.svg'],
dest: 'assets/icons/svg-min/',
ext: '.svg'
}
]
ext: '.svg',
},
],
},
options: {
plugins: [
Expand All @@ -84,11 +46,11 @@ module.exports = function(grunt) {
{ removeTitle: true }, // "leaflet-toolbar" lets us specify the title attribute later
{
removeAttrs: {
attrs: ['xmlns', 'fill']
}
}
]
}
attrs: ['xmlns', 'fill'],
},
},
],
},
},

svg_sprite: {
Expand All @@ -105,29 +67,29 @@ module.exports = function(grunt) {
mode: {
symbol: {
sprite: 'sprite.symbol.svg',
example: true
}
}
}
}
example: true,
},
},
},
},
},

watch: {
options: {
livereload: true
livereload: true,
},
source: {
files: ['src/**/*.js', 'test/**/*.js', 'Gruntfile.js'],
tasks: ['jshint', 'karma:development:start']
}
}
tasks: ['eslint', 'karma:development:start'],
},
},
});

/* Run tests once. */
grunt.registerTask('test', ['jshint', 'karma:test']);
grunt.registerTask('test', ['eslint', 'karma:test']);

grunt.registerTask('build', [
'jshint',
'eslint',
'karma:development:start',
'coverage',
'webpack',
Expand All @@ -136,7 +98,7 @@ module.exports = function(grunt) {
// recompile svg icon sprite
grunt.registerTask('icons', ['svgmin', 'svg_sprite']);

grunt.registerTask('coverage', 'Custom commmand-line reporter for karma-coverage', function() {
grunt.registerTask('coverage', 'CLI reporter for karma-coverage', function() {
var coverageReports = grunt.file.expand('coverage/*/coverage.txt');
var reports = {};
var report; var i; var len;
Expand Down
57 changes: 0 additions & 57 deletions TESTING.md

This file was deleted.

Loading

0 comments on commit 7d51473

Please sign in to comment.