Added jshint file for unit tests, and grunt task to verify test syntax.
This commit is contained in:
@@ -13,13 +13,12 @@
|
||||
"rjs-build-analysis": "0.0.3",
|
||||
"grunt": "~0.4.0",
|
||||
"grunt-ngmin": "0.0.3",
|
||||
"grunt-contrib": "~0.8.0",
|
||||
"grunt-contrib-less": "~0.7.0",
|
||||
"grunt-contrib-copy": "~0.4.1",
|
||||
"grunt-git-describe": "~2.3.2",
|
||||
"grunt-contrib-clean": "~0.5.0",
|
||||
"grunt-contrib-cssmin": "~0.6.1",
|
||||
"grunt-contrib-jshint": "~0.6.0",
|
||||
"grunt-contrib-jshint": "~0.10.0",
|
||||
"grunt-string-replace": "~0.2.4",
|
||||
"grunt-contrib-htmlmin": "~0.1.3",
|
||||
"grunt-contrib-requirejs": "~0.4.1",
|
||||
@@ -44,7 +43,8 @@
|
||||
"grunt-karma": "~0.6.2",
|
||||
"karma-mocha": "~0.1.1",
|
||||
"karma-expect": "~1.0.0",
|
||||
"grunt-cli": "~0.1.13"
|
||||
"grunt-cli": "~0.1.13",
|
||||
"jshint-stylish": "~0.1.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": "0.10.x",
|
||||
|
||||
38
src/test/.jshintrc
Normal file
38
src/test/.jshintrc
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"browser": true,
|
||||
"bitwise":false,
|
||||
"curly": true,
|
||||
"eqnull": true,
|
||||
"globalstrict": true,
|
||||
"devel": true,
|
||||
"eqeqeq": true,
|
||||
"forin": false,
|
||||
"immed": true,
|
||||
"supernew": true,
|
||||
"expr": true,
|
||||
"indent": 2,
|
||||
"latedef": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"undef": true,
|
||||
"boss": true,
|
||||
"trailing": false,
|
||||
"laxbreak": true,
|
||||
"laxcomma": true,
|
||||
"sub": true,
|
||||
"unused": true,
|
||||
"maxlen": 140,
|
||||
|
||||
"globals": {
|
||||
"expect": true,
|
||||
"it": true,
|
||||
"describe": true,
|
||||
"define": true,
|
||||
"module": true,
|
||||
"beforeEach": true,
|
||||
"inject": true,
|
||||
"require": true,
|
||||
"setImmediate": true
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
module.exports = function(config) {
|
||||
'use strict';
|
||||
|
||||
config.set({
|
||||
basePath: '../',
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
define([],
|
||||
function() {
|
||||
'use strict';
|
||||
|
||||
return {
|
||||
create: function() {
|
||||
@@ -34,7 +35,7 @@ define([],
|
||||
},
|
||||
refresh: false
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ define([
|
||||
'underscore',
|
||||
'services/filterSrv'
|
||||
], function(dashboardMock, _) {
|
||||
'use strict';
|
||||
|
||||
describe('filterSrv', function() {
|
||||
var _filterSrv;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
define([
|
||||
'services/graphite/gfunc'
|
||||
], function(gfunc) {
|
||||
'use strict';
|
||||
|
||||
describe('when creating func instance from func names', function() {
|
||||
|
||||
@@ -19,7 +20,6 @@ define([
|
||||
});
|
||||
|
||||
it('should return func instance from funcDef', function() {
|
||||
var func = gfunc.createFuncInstance('sum');
|
||||
var func = gfunc.createFuncInstance(func.def);
|
||||
expect(func).to.be.ok();
|
||||
});
|
||||
@@ -74,7 +74,7 @@ define([
|
||||
it('should parse numbers as float', function() {
|
||||
var func = gfunc.createFuncInstance('scale');
|
||||
func.updateParam('0.001', 0);
|
||||
expect(func.params[0]).to.be(0.001);
|
||||
expect(func.params[0]).to.be(0.001);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -100,7 +100,7 @@ define([
|
||||
expect(func.params[0]).to.be(4);
|
||||
expect(func.params[1]).to.be(undefined);
|
||||
expect(func.text).to.be('aliasByNode(4)');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
define([
|
||||
'mocks/dashboard-mock',
|
||||
'underscore',
|
||||
'services/filterSrv'
|
||||
], function(dashboardMock, _) {
|
||||
], function() {
|
||||
'use strict';
|
||||
|
||||
describe('graphiteTargetCtrl', function() {
|
||||
var _filterSrv;
|
||||
var _targetCtrl;
|
||||
|
||||
beforeEach(module('kibana.services'));
|
||||
beforeEach(module(function($provide){
|
||||
@@ -20,8 +18,6 @@ define([
|
||||
|
||||
describe('init', function() {
|
||||
beforeEach(function() {
|
||||
_filterSrv.add({ name: 'test', current: { value: 'oogle' } });
|
||||
_filterSrv.init();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
define([
|
||||
'kbn'
|
||||
], function(kbn) {
|
||||
'use strict';
|
||||
|
||||
describe('millisecond formating', function() {
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
define([
|
||||
'services/graphite/lexer'
|
||||
], function(Lexer) {
|
||||
'use strict';
|
||||
|
||||
describe('when lexing graphite expression', function() {
|
||||
|
||||
@@ -90,7 +91,7 @@ define([
|
||||
|
||||
it('should handle float parameters', function() {
|
||||
var lexer = new Lexer("alias(metric, 0.002)");
|
||||
var tokens = lexer.tokenize();
|
||||
var tokens = lexer.tokenize();
|
||||
expect(tokens[4].type).to.be('number');
|
||||
expect(tokens[4].value).to.be('0.002');
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
define([
|
||||
'services/graphite/parser'
|
||||
], function(Parser) {
|
||||
'use strict';
|
||||
|
||||
describe('when parsing', function() {
|
||||
|
||||
@@ -103,7 +104,7 @@ define([
|
||||
var parser = new Parser("sum(test.[[server]].count)");
|
||||
var rootNode = parser.getAst();
|
||||
|
||||
expect(rootNode.message).to.be(undefined)
|
||||
expect(rootNode.message).to.be(undefined);
|
||||
expect(rootNode.params[0].type).to.be('metric');
|
||||
expect(rootNode.params[0].segments[1].type).to.be('template');
|
||||
expect(rootNode.params[0].segments[1].value).to.be('server');
|
||||
@@ -141,8 +142,8 @@ define([
|
||||
|
||||
it('handle float function arguments', function() {
|
||||
var parser = new Parser('scale(test, 0.002)');
|
||||
var rootNode = parser.getAst();
|
||||
expect(rootNode.type).to.be('function');
|
||||
var rootNode = parser.getAst();
|
||||
expect(rootNode.type).to.be('function');
|
||||
expect(rootNode.params[1].type).to.be('number');
|
||||
expect(rootNode.params[1].value).to.be(0.002);
|
||||
});
|
||||
|
||||
@@ -8,7 +8,6 @@ require.config({
|
||||
kbn: 'components/kbn',
|
||||
|
||||
settings: 'components/settings',
|
||||
crypto: '../vendor/crypto.min',
|
||||
underscore: 'components/underscore.extended',
|
||||
'underscore-src': '../vendor/underscore',
|
||||
|
||||
@@ -29,7 +28,6 @@ require.config({
|
||||
jquery: '../vendor/jquery/jquery-1.8.0',
|
||||
|
||||
bootstrap: '../vendor/bootstrap/bootstrap',
|
||||
bindonce: '../vendor/angular/bindonce',
|
||||
|
||||
'jquery-ui': '../vendor/jquery/jquery-ui-1.10.3',
|
||||
|
||||
@@ -106,6 +104,7 @@ require([
|
||||
'angular',
|
||||
'angularMocks',
|
||||
], function(angular) {
|
||||
'use strict';
|
||||
|
||||
angular.module('kibana', []);
|
||||
angular.module('kibana.services', []);
|
||||
|
||||
@@ -3,6 +3,7 @@ module.exports = function(grunt) {
|
||||
// Concat and Minify the src directory into dist
|
||||
grunt.registerTask('build', [
|
||||
'jshint:source',
|
||||
'jshint:tests',
|
||||
'clean:on_start',
|
||||
'less:src',
|
||||
'copy:everything_but_less_to_temp',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Lint and build CSS
|
||||
module.exports = function(grunt) {
|
||||
grunt.registerTask('default', ['jshint:source', 'less:src']);
|
||||
grunt.registerTask('default', ['jshint:source', 'jshint:tests', 'less:src']);
|
||||
grunt.registerTask('test', ['default', 'karma:test']);
|
||||
};
|
||||
@@ -1,13 +1,18 @@
|
||||
module.exports = function(config) {
|
||||
return {
|
||||
// just lint the source dir
|
||||
source: {
|
||||
files: {
|
||||
src: ['Gruntfile.js', '<%= srcDir %>/app/**/*.js']
|
||||
src: ['Gruntfile.js', '<%= srcDir %>/app/**/*.js'],
|
||||
}
|
||||
},
|
||||
tests: {
|
||||
files: {
|
||||
src: ['<%= srcDir %>/test/**/*.js'],
|
||||
}
|
||||
},
|
||||
options: {
|
||||
jshintrc: '<%= baseDir %>/.jshintrc',
|
||||
jshintrc: true,
|
||||
reporter: require('jshint-stylish'),
|
||||
ignores: [
|
||||
'node_modules/*',
|
||||
'dist/*',
|
||||
|
||||
Reference in New Issue
Block a user