Commit 4029dc31 by Torkel Ödegaard

Added jshint file for unit tests, and grunt task to verify test syntax.

parent 67953834
...@@ -13,13 +13,12 @@ ...@@ -13,13 +13,12 @@
"rjs-build-analysis": "0.0.3", "rjs-build-analysis": "0.0.3",
"grunt": "~0.4.0", "grunt": "~0.4.0",
"grunt-ngmin": "0.0.3", "grunt-ngmin": "0.0.3",
"grunt-contrib": "~0.8.0",
"grunt-contrib-less": "~0.7.0", "grunt-contrib-less": "~0.7.0",
"grunt-contrib-copy": "~0.4.1", "grunt-contrib-copy": "~0.4.1",
"grunt-git-describe": "~2.3.2", "grunt-git-describe": "~2.3.2",
"grunt-contrib-clean": "~0.5.0", "grunt-contrib-clean": "~0.5.0",
"grunt-contrib-cssmin": "~0.6.1", "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-string-replace": "~0.2.4",
"grunt-contrib-htmlmin": "~0.1.3", "grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-requirejs": "~0.4.1", "grunt-contrib-requirejs": "~0.4.1",
...@@ -44,7 +43,8 @@ ...@@ -44,7 +43,8 @@
"grunt-karma": "~0.6.2", "grunt-karma": "~0.6.2",
"karma-mocha": "~0.1.1", "karma-mocha": "~0.1.1",
"karma-expect": "~1.0.0", "karma-expect": "~1.0.0",
"grunt-cli": "~0.1.13" "grunt-cli": "~0.1.13",
"jshint-stylish": "~0.1.5"
}, },
"engines": { "engines": {
"node": "0.10.x", "node": "0.10.x",
......
{
"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
}
}
\ No newline at end of file
module.exports = function(config) { module.exports = function(config) {
'use strict';
config.set({ config.set({
basePath: '../', basePath: '../',
......
define([], define([],
function() { function() {
'use strict';
return { return {
create: function() { create: function() {
...@@ -34,7 +35,7 @@ define([], ...@@ -34,7 +35,7 @@ define([],
}, },
refresh: false refresh: false
} }
} };
} }
} };
}); });
...@@ -3,6 +3,7 @@ define([ ...@@ -3,6 +3,7 @@ define([
'underscore', 'underscore',
'services/filterSrv' 'services/filterSrv'
], function(dashboardMock, _) { ], function(dashboardMock, _) {
'use strict';
describe('filterSrv', function() { describe('filterSrv', function() {
var _filterSrv; var _filterSrv;
......
define([ define([
'services/graphite/gfunc' 'services/graphite/gfunc'
], function(gfunc) { ], function(gfunc) {
'use strict';
describe('when creating func instance from func names', function() { describe('when creating func instance from func names', function() {
...@@ -19,7 +20,6 @@ define([ ...@@ -19,7 +20,6 @@ define([
}); });
it('should return func instance from funcDef', function() { it('should return func instance from funcDef', function() {
var func = gfunc.createFuncInstance('sum');
var func = gfunc.createFuncInstance(func.def); var func = gfunc.createFuncInstance(func.def);
expect(func).to.be.ok(); expect(func).to.be.ok();
}); });
...@@ -74,7 +74,7 @@ define([ ...@@ -74,7 +74,7 @@ define([
it('should parse numbers as float', function() { it('should parse numbers as float', function() {
var func = gfunc.createFuncInstance('scale'); var func = gfunc.createFuncInstance('scale');
func.updateParam('0.001', 0); 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([ ...@@ -100,7 +100,7 @@ define([
expect(func.params[0]).to.be(4); expect(func.params[0]).to.be(4);
expect(func.params[1]).to.be(undefined); expect(func.params[1]).to.be(undefined);
expect(func.text).to.be('aliasByNode(4)'); expect(func.text).to.be('aliasByNode(4)');
}); });
}); });
}); });
......
define([ define([
'mocks/dashboard-mock', ], function() {
'underscore', 'use strict';
'services/filterSrv'
], function(dashboardMock, _) {
describe('graphiteTargetCtrl', function() { describe('graphiteTargetCtrl', function() {
var _filterSrv; var _targetCtrl;
beforeEach(module('kibana.services')); beforeEach(module('kibana.services'));
beforeEach(module(function($provide){ beforeEach(module(function($provide){
...@@ -20,8 +18,6 @@ define([ ...@@ -20,8 +18,6 @@ define([
describe('init', function() { describe('init', function() {
beforeEach(function() { beforeEach(function() {
_filterSrv.add({ name: 'test', current: { value: 'oogle' } });
_filterSrv.init();
}); });
}); });
}); });
......
define([ define([
'kbn' 'kbn'
], function(kbn) { ], function(kbn) {
'use strict';
describe('millisecond formating', function() { describe('millisecond formating', function() {
......
define([ define([
'services/graphite/lexer' 'services/graphite/lexer'
], function(Lexer) { ], function(Lexer) {
'use strict';
describe('when lexing graphite expression', function() { describe('when lexing graphite expression', function() {
...@@ -90,7 +91,7 @@ define([ ...@@ -90,7 +91,7 @@ define([
it('should handle float parameters', function() { it('should handle float parameters', function() {
var lexer = new Lexer("alias(metric, 0.002)"); 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].type).to.be('number');
expect(tokens[4].value).to.be('0.002'); expect(tokens[4].value).to.be('0.002');
}); });
......
define([ define([
'services/graphite/parser' 'services/graphite/parser'
], function(Parser) { ], function(Parser) {
'use strict';
describe('when parsing', function() { describe('when parsing', function() {
...@@ -103,7 +104,7 @@ define([ ...@@ -103,7 +104,7 @@ define([
var parser = new Parser("sum(test.[[server]].count)"); var parser = new Parser("sum(test.[[server]].count)");
var rootNode = parser.getAst(); 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].type).to.be('metric');
expect(rootNode.params[0].segments[1].type).to.be('template'); expect(rootNode.params[0].segments[1].type).to.be('template');
expect(rootNode.params[0].segments[1].value).to.be('server'); expect(rootNode.params[0].segments[1].value).to.be('server');
...@@ -141,8 +142,8 @@ define([ ...@@ -141,8 +142,8 @@ define([
it('handle float function arguments', function() { it('handle float function arguments', function() {
var parser = new Parser('scale(test, 0.002)'); var parser = new Parser('scale(test, 0.002)');
var rootNode = parser.getAst(); var rootNode = parser.getAst();
expect(rootNode.type).to.be('function'); expect(rootNode.type).to.be('function');
expect(rootNode.params[1].type).to.be('number'); expect(rootNode.params[1].type).to.be('number');
expect(rootNode.params[1].value).to.be(0.002); expect(rootNode.params[1].value).to.be(0.002);
}); });
......
...@@ -8,7 +8,6 @@ require.config({ ...@@ -8,7 +8,6 @@ require.config({
kbn: 'components/kbn', kbn: 'components/kbn',
settings: 'components/settings', settings: 'components/settings',
crypto: '../vendor/crypto.min',
underscore: 'components/underscore.extended', underscore: 'components/underscore.extended',
'underscore-src': '../vendor/underscore', 'underscore-src': '../vendor/underscore',
...@@ -29,7 +28,6 @@ require.config({ ...@@ -29,7 +28,6 @@ require.config({
jquery: '../vendor/jquery/jquery-1.8.0', jquery: '../vendor/jquery/jquery-1.8.0',
bootstrap: '../vendor/bootstrap/bootstrap', bootstrap: '../vendor/bootstrap/bootstrap',
bindonce: '../vendor/angular/bindonce',
'jquery-ui': '../vendor/jquery/jquery-ui-1.10.3', 'jquery-ui': '../vendor/jquery/jquery-ui-1.10.3',
...@@ -106,6 +104,7 @@ require([ ...@@ -106,6 +104,7 @@ require([
'angular', 'angular',
'angularMocks', 'angularMocks',
], function(angular) { ], function(angular) {
'use strict';
angular.module('kibana', []); angular.module('kibana', []);
angular.module('kibana.services', []); angular.module('kibana.services', []);
......
...@@ -3,6 +3,7 @@ module.exports = function(grunt) { ...@@ -3,6 +3,7 @@ module.exports = function(grunt) {
// Concat and Minify the src directory into dist // Concat and Minify the src directory into dist
grunt.registerTask('build', [ grunt.registerTask('build', [
'jshint:source', 'jshint:source',
'jshint:tests',
'clean:on_start', 'clean:on_start',
'less:src', 'less:src',
'copy:everything_but_less_to_temp', 'copy:everything_but_less_to_temp',
......
// Lint and build CSS // Lint and build CSS
module.exports = function(grunt) { 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']); grunt.registerTask('test', ['default', 'karma:test']);
}; };
\ No newline at end of file
module.exports = function(config) { module.exports = function(config) {
return { return {
// just lint the source dir
source: { source: {
files: { files: {
src: ['Gruntfile.js', '<%= srcDir %>/app/**/*.js'] src: ['Gruntfile.js', '<%= srcDir %>/app/**/*.js'],
}
},
tests: {
files: {
src: ['<%= srcDir %>/test/**/*.js'],
} }
}, },
options: { options: {
jshintrc: '<%= baseDir %>/.jshintrc', jshintrc: true,
reporter: require('jshint-stylish'),
ignores: [ ignores: [
'node_modules/*', 'node_modules/*',
'dist/*', 'dist/*',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment