mediawiki-extensions-Popups/Gruntfile.js
Sam Smith 19349c0108 Add BOOT action
Changes:
* Make grunt:qunit run all QUnit tests in those modules whose names
  being with "ext.popups".
* Add ext.popups/index.js, which initialises the mw.popups namespace.
* Add ext.popups/userSettings.js, which contains the code that deals
  with interacting with the User Agent's storage.
* Add ext.popups/experiment.js, which contains the code that that
  decides whether or not the user is in the experiment condition.
* Add tests for both units, converting existing tests where appropriate.
* Remove the associated code from ext.popups.core/ext.popups.core.js.
* Finally, dispatch the BOOT action against the store in
  ext.popups/boot.js.

Change-Id: I697207677304bd49c7cfe1d37bb0a4af7810f387
2016-11-09 10:40:59 +00:00

111 lines
2.3 KiB
JavaScript

// jscs:disable jsDoc
/*jshint node:true */
module.exports = function ( grunt ) {
var QUNIT_URL_BASE = 'http://localhost:8080/wiki/Special:JavaScriptTest/qunit/plain';
grunt.loadNpmTasks( 'grunt-banana-checker' );
grunt.loadNpmTasks( 'grunt-contrib-jshint' );
grunt.loadNpmTasks( 'grunt-contrib-qunit' );
grunt.loadNpmTasks( 'grunt-contrib-watch' );
grunt.loadNpmTasks( 'grunt-jscs' );
grunt.loadNpmTasks( 'grunt-jsonlint' );
grunt.loadNpmTasks( 'grunt-stylelint' );
grunt.initConfig( {
banana: {
all: 'i18n/'
},
jscs: {
options: {
config: '.jscsrc'
},
main: '<%= jshint.all %>',
test: {
options: {
config: 'tests/.jscsrc.js'
},
files: {
src: [
'tests/qunit/**/*.js',
'!tests/qunit/ext.popups.core.test.js'
]
}
}
},
jshint: {
options: {
jshintrc: true
},
all: [
'*.js',
'**/*.js',
'!node_modules/**',
'!resources/ext.popups.lib/**',
// FIXME: Remove ignores for legacy code upon removal/refactor
'!resources/ext.popups.core/**',
'!resources/ext.popups.desktop/**',
'!resources/ext.popups.images/**',
'!resources/ext.popups.renderer.desktopRenderer/**',
'!resources/ext.popups.schemaPopups/**',
'!resources/ext.popups.schemaPopups.utils/**',
'!resources/ext.popups.targets.desktopTarget/**',
// End legacy code
'!tests/qunit/**'
],
test: {
files: {
src: 'tests/qunit/**/*.js'
}
}
},
jsonlint: {
all: [
'*.json',
'**/*.json',
'!node_modules/**'
]
},
qunit: {
all: {
options: {
summaryOnly: true,
urls: [
// Execute any QUnit test in those module whose names begin with
// "ext.popups".
QUNIT_URL_BASE + '?filter=ext.popups'
]
}
}
},
stylelint: {
options: {
syntax: 'less'
},
all: [
'resources/**/*.less'
]
},
watch: {
lint: {
files: [ 'resources/**/*.js', 'tests/qunit/**/*.js' ],
tasks: [ 'lint' ]
},
scripts: {
files: [ 'resources/**/*.js', 'tests/qunit/**/*.js' ],
tasks: [ 'test' ]
},
configFiles: {
files: [ 'Gruntfile.js' ],
options: {
reload: true
}
}
}
} );
grunt.registerTask( 'lint', [ 'jshint', 'jscs', 'jsonlint', 'banana' ] );
grunt.registerTask( 'test', [ 'qunit' ] );
grunt.registerTask( 'default', [ 'test', 'lint' ] );
};