diff --git a/.jshintrc b/.jshintrc index 3aae3b5b89e9..de6a67700b6c 100644 --- a/.jshintrc +++ b/.jshintrc @@ -33,5 +33,6 @@ "sub": true, "maxlen": 140, "-W084": true, - "maxerr": 10 -} + "maxerr": 10, + "scripturl": true +} \ No newline at end of file diff --git a/tasks/config/jshint.js b/tasks/config/jshint.js index 52b2b6accd32..89bf0d1279f5 100644 --- a/tasks/config/jshint.js +++ b/tasks/config/jshint.js @@ -1,13 +1,13 @@ -module.exports = function(config) { +module.exports = function (config) { return { // just lint the source dir source: { files: { - src: ['Gruntfile.js', '<%= root %>/src/**/*.js'] + src: ['Gruntfile.js', '<%= src %>/**/*.js', '<%= unitTestDir %>/**/*.js', '<%= root %>/tasks/**/*.js'] } }, options: { - jshintrc: '<%= root %>/.jshintrc', + jshintrc: true, ignores: [ 'node_modules/*', 'dist/*', diff --git a/tasks/test.js b/tasks/test.js index d90b35a46a41..cc19319f8f26 100644 --- a/tasks/test.js +++ b/tasks/test.js @@ -1,6 +1,7 @@ module.exports = function (grunt) { /* jshint scripturl:true */ grunt.registerTask('test', [ + 'jshint', 'connect:test', 'jade:test', 'mocha:unit' diff --git a/test/unit/fixtures/field_mapping.js b/test/unit/fixtures/field_mapping.js new file mode 100644 index 000000000000..baed32937ed1 --- /dev/null +++ b/test/unit/fixtures/field_mapping.js @@ -0,0 +1,18 @@ +define(function (require) { + return { + test: { + mappings: { + testType: { + 'foo.bar': { + full_name: 'foo.bar', + mapping: { + bar: { + type: 'string' + } + } + } + } + } + } + }; +}); \ No newline at end of file diff --git a/test/unit/index.html b/test/unit/index.html index be97e7f366fa..00f9f43397c4 100644 --- a/test/unit/index.html +++ b/test/unit/index.html @@ -14,7 +14,7 @@ } } }); -require(["/specs/apps/dashboard/index.js","/specs/calculate_indices.js","/specs/courier.js","/specs/data_source.js","/specs/mapper.js"], function () { +require(["/fixtures/field_mapping.js","/specs/calculate_indices.js","/specs/courier.js","/specs/data_source.js","/specs/mapper.js"], function () { window.mochaRunner = mocha.run().on('end', function () { window.mochaResults = this.stats; }); diff --git a/test/unit/specs/mapper.js b/test/unit/specs/mapper.js index cabae5274cdc..108016a9654f 100644 --- a/test/unit/specs/mapper.js +++ b/test/unit/specs/mapper.js @@ -5,6 +5,7 @@ define(function (require) { var Courier = require('courier/courier'); var DataSource = require('courier/data_source/data_source'); var Mapper = require('courier/mapper'); + var fieldMapping = require('../fixtures/field_mapping.js'); var client = new elasticsearch.Client({ host: 'localhost:9200', @@ -26,17 +27,7 @@ define(function (require) { // Stub out a mini mapping response. sinon.stub(client.indices, 'getFieldMapping',function (params, callback) { if(params.index === 'valid') { - setTimeout(callback(undefined,{ - test: { - mappings: { - testType: { - 'foo.bar': { - full_name: 'foo.bar', - mapping: { - bar: { - type: 'string' - } } } } } } } - ),0); + setTimeout(callback(undefined, fieldMapping),0); } else { setTimeout(callback('Error: Not Found',undefined)); }