mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
modified testing dir jshint rules to use 'white' formatting, and fixed style issues
This commit is contained in:
parent
534dcf789a
commit
f5ba7bcdda
6 changed files with 43 additions and 32 deletions
|
@ -1,8 +1,6 @@
|
|||
{
|
||||
"extends": "../src/.jshintrc",
|
||||
|
||||
"white": false,
|
||||
|
||||
"globals": {
|
||||
"module": false,
|
||||
"inject": false,
|
||||
|
|
|
@ -4,7 +4,7 @@ define(function (require) {
|
|||
var _ = require('lodash');
|
||||
var $ = require('jquery');
|
||||
var sinon = require('sinon/sinon');
|
||||
var configFile = require('../../../config.js');
|
||||
var configFile = require('configFile');
|
||||
|
||||
// Load the kibana app dependencies.
|
||||
require('angular-route');
|
||||
|
@ -19,13 +19,13 @@ define(function (require) {
|
|||
describe('Mapper', function () {
|
||||
var $scope;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
|
||||
// Start the kibana module
|
||||
module('kibana');
|
||||
|
||||
// Create the scope
|
||||
inject(function($rootScope, $controller) {
|
||||
inject(function ($rootScope, $controller) {
|
||||
$scope = $rootScope.$new();
|
||||
var dashCtrl = $controller('dashboard', {
|
||||
$scope: $scope
|
||||
|
|
|
@ -2,23 +2,23 @@ define(function (require) {
|
|||
|
||||
var angular = require('angular');
|
||||
|
||||
angular.module('app/dashboard',[]);
|
||||
angular.module('app/dashboard', []);
|
||||
|
||||
// Need this because the controller requires it
|
||||
angular.module('kibana/directives',[]);
|
||||
angular.module('kibana/directives', []);
|
||||
|
||||
// create mock service for courier
|
||||
var mock = {
|
||||
getvalue: function () {}
|
||||
};
|
||||
|
||||
angular.module('kibana/services',[])
|
||||
.service('courier',function () {
|
||||
angular.module('kibana/services', [])
|
||||
.service('courier', function () {
|
||||
return mock;
|
||||
});
|
||||
|
||||
// Could probably get rid of ngRoute if you want to stub it
|
||||
angular.module('kibana',['ngRoute','kibana/services','app/dashboard']);
|
||||
angular.module('kibana', ['ngRoute', 'kibana/services', 'app/dashboard']);
|
||||
|
||||
|
||||
});
|
|
@ -4,19 +4,19 @@ define(function (require) {
|
|||
|
||||
describe('calculateIndices()', function () {
|
||||
|
||||
describe('error checking', function() {
|
||||
describe('error checking', function () {
|
||||
it('should throw an error if start is > end', function () {
|
||||
expect(function () { calculateIndices(moment().add('day', 1), moment()); }).to.throwError();
|
||||
});
|
||||
it('should throw an error if interval is not [ hour, day, week, year ]', function () {
|
||||
expect(function () { calculateIndices(moment().subtract('day', 1), moment(), 'century' ); }).to.throwError();
|
||||
expect(function () { calculateIndices(moment().subtract('day', 1), moment(), 'century'); }).to.throwError();
|
||||
});
|
||||
it('should throw an error if pattern is not set', function () {
|
||||
expect(function () { calculateIndices(moment().subtract('day', 1), moment(), 'hour' ); }).to.throwError();
|
||||
expect(function () { calculateIndices(moment().subtract('day', 1), moment(), 'hour'); }).to.throwError();
|
||||
});
|
||||
});
|
||||
|
||||
describe('hourly interval', function() {
|
||||
describe('hourly interval', function () {
|
||||
beforeEach(function () {
|
||||
var date = '2014-01-15 04:30:10';
|
||||
this.start = moment.utc(date).subtract('hours', 4);
|
||||
|
@ -36,7 +36,7 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
describe('daily interval', function() {
|
||||
describe('daily interval', function () {
|
||||
beforeEach(function () {
|
||||
var date = '2014-01-15 04:30:10';
|
||||
this.start = moment.utc(date).subtract('days', 4);
|
||||
|
@ -56,7 +56,7 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
describe('weekly interval', function() {
|
||||
describe('weekly interval', function () {
|
||||
beforeEach(function () {
|
||||
var date = '2014-01-15 04:30:10';
|
||||
this.start = moment.utc(date).subtract('week', 4);
|
||||
|
@ -76,7 +76,7 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
describe('yearly interval', function() {
|
||||
describe('yearly interval', function () {
|
||||
beforeEach(function () {
|
||||
var date = '2014-01-15 04:30:10';
|
||||
this.start = moment.utc(date).subtract('years', 4);
|
||||
|
|
|
@ -13,7 +13,18 @@ define(function (require) {
|
|||
expect(courier).to.be.a(Courier);
|
||||
});
|
||||
|
||||
it('knows when a DataSource object has event listeners for the results event');
|
||||
it('knows when a DataSource object has event listeners for the results event', function () {
|
||||
var courier = new Courier();
|
||||
var ds = courier.createSource('doc');
|
||||
|
||||
expect(courier._openSources('doc')).to.have.length(0);
|
||||
ds.on('results', function () {});
|
||||
expect(courier._openSources('doc')).to.have.length(1);
|
||||
ds.removeAllListeners('results');
|
||||
expect(courier._openSources('doc')).to.have.length(0);
|
||||
});
|
||||
|
||||
|
||||
it('executes queries on the interval for searches that have listeners for results');
|
||||
|
||||
describe('events', function () {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
define(function (require) {
|
||||
var elasticsearch = require('../bower_components/elasticsearch/elasticsearch.js');
|
||||
var elasticsearch = require('bower_components/elasticsearch/elasticsearch');
|
||||
var _ = require('lodash');
|
||||
var sinon = require('sinon/sinon');
|
||||
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 fieldMapping = require('../fixtures/field_mapping');
|
||||
|
||||
var client = new elasticsearch.Client({
|
||||
host: 'localhost:9200',
|
||||
|
@ -18,30 +18,32 @@ define(function (require) {
|
|||
describe('Mapper', function () {
|
||||
var server, source, mapper;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
source = courier.createSource('search')
|
||||
.index('valid')
|
||||
.size(5);
|
||||
mapper = new Mapper(courier);
|
||||
|
||||
// Stub out a mini mapping response.
|
||||
sinon.stub(client.indices, 'getFieldMapping',function (params, callback) {
|
||||
if(params.index === 'valid') {
|
||||
setTimeout(callback(undefined, fieldMapping),0);
|
||||
sinon.stub(client.indices, 'getFieldMapping', function (params, callback) {
|
||||
if (params.index === 'valid') {
|
||||
setTimeout(callback(undefined, fieldMapping), 0);
|
||||
} else {
|
||||
setTimeout(callback('Error: Not Found',undefined));
|
||||
setTimeout(callback('Error: Not Found', undefined));
|
||||
}
|
||||
});
|
||||
|
||||
sinon.stub(client, 'getSource', function (params, callback) {
|
||||
if(params.id === 'valid') {
|
||||
setTimeout(callback(undefined,{'foo.bar': {'type': 'string'}}),0);
|
||||
if (params.id === 'valid') {
|
||||
setTimeout(callback(undefined, {'foo.bar': {'type': 'string'}}), 0);
|
||||
} else {
|
||||
setTimeout(callback('Error: Not Found',undefined),0);
|
||||
setTimeout(callback('Error: Not Found', undefined), 0);
|
||||
}
|
||||
});
|
||||
|
||||
sinon.stub(client, 'delete', function (params, callback) {callback(undefined,true);});
|
||||
sinon.stub(client, 'delete', function (params, callback) {
|
||||
callback(undefined, true);
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
|
@ -57,7 +59,7 @@ define(function (require) {
|
|||
});
|
||||
|
||||
it('has getFieldsFromMapping function that returns a mapping', function (done) {
|
||||
mapper.getFieldsFromMapping(source,function (err, mapping) {
|
||||
mapper.getFieldsFromMapping(source, function (err, mapping) {
|
||||
expect(client.indices.getFieldMapping.called).to.be(true);
|
||||
expect(mapping['foo.bar'].type).to.be('string');
|
||||
done();
|
||||
|
@ -69,7 +71,7 @@ define(function (require) {
|
|||
.index('invalid')
|
||||
.size(5);
|
||||
|
||||
mapper.getFieldsFromCache(source,function (err, mapping) {
|
||||
mapper.getFieldsFromCache(source, function (err, mapping) {
|
||||
expect(client.getSource.called).to.be(true);
|
||||
expect(err).to.be('Error: Not Found');
|
||||
done();
|
||||
|
@ -77,7 +79,7 @@ define(function (require) {
|
|||
});
|
||||
|
||||
it('has getFieldsFromCache that returns a mapping', function (done) {
|
||||
mapper.getFieldsFromCache(source,function (err, mapping) {
|
||||
mapper.getFieldsFromCache(source, function (err, mapping) {
|
||||
expect(client.getSource.called).to.be(true);
|
||||
expect(mapping['foo.bar'].type).to.be('string');
|
||||
done();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue