-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
148 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import d3 from 'd3'; | ||
import _ from 'lodash'; | ||
import ngMock from 'ng_mock'; | ||
import expect from 'expect.js'; | ||
import VislibLibVisConfigProvider from 'ui/vislib/lib/vis_config'; | ||
import PersistedStatePersistedStateProvider from 'ui/persisted_state/persisted_state'; | ||
|
||
describe('Vislib VisConfig Class Test Suite', function () { | ||
let visConfig; | ||
let el; | ||
const data = { | ||
hits: 621, | ||
ordered: { | ||
date: true, | ||
interval: 30000, | ||
max: 1408734982458, | ||
min: 1408734082458 | ||
}, | ||
series: [ | ||
{ | ||
label: 'Count', | ||
values: [ | ||
{ | ||
x: 1408734060000, | ||
y: 8 | ||
}, | ||
{ | ||
x: 1408734090000, | ||
y: 23 | ||
}, | ||
{ | ||
x: 1408734120000, | ||
y: 30 | ||
}, | ||
{ | ||
x: 1408734150000, | ||
y: 28 | ||
}, | ||
{ | ||
x: 1408734180000, | ||
y: 36 | ||
}, | ||
{ | ||
x: 1408734210000, | ||
y: 30 | ||
}, | ||
{ | ||
x: 1408734240000, | ||
y: 26 | ||
}, | ||
{ | ||
x: 1408734270000, | ||
y: 22 | ||
}, | ||
{ | ||
x: 1408734300000, | ||
y: 29 | ||
}, | ||
{ | ||
x: 1408734330000, | ||
y: 24 | ||
} | ||
] | ||
} | ||
], | ||
xAxisLabel: 'Date Histogram', | ||
yAxisLabel: 'Count' | ||
}; | ||
|
||
beforeEach(ngMock.module('kibana')); | ||
beforeEach(ngMock.inject(function (Private) { | ||
const VisConfig = Private(VislibLibVisConfigProvider); | ||
const PersistedState = Private(PersistedStatePersistedStateProvider); | ||
el = d3.select('body') | ||
.attr('class', 'vis-wrapper') | ||
.node(); | ||
|
||
visConfig = new VisConfig({ | ||
type: 'histogram', | ||
el: el | ||
}, data, new PersistedState()); | ||
})); | ||
|
||
describe('get Method', function () { | ||
it('should be a function', function () { | ||
expect(_.isFunction(visConfig.set)).to.be(true); | ||
}); | ||
|
||
it('should get the property', function () { | ||
expect(visConfig.get('el')).to.be(el); | ||
expect(visConfig.get('type')).to.be('histogram'); | ||
}); | ||
|
||
it('should return defaults if property does not exist', function () { | ||
expect(visConfig.get('this.does.not.exist', 'defaults')).to.be('defaults'); | ||
}); | ||
|
||
it('should throw an error if property does not exist and defaults were not provided', function () { | ||
expect(visConfig.get('this.does.not.exist')).to.throwError(); | ||
}); | ||
}); | ||
|
||
describe('set Method', function () { | ||
it('should be a function', function () { | ||
expect(_.isFunction(visConfig.set)).to.be(true); | ||
}); | ||
|
||
it('should set a property', function () { | ||
visConfig.set('this.does.not.exist', 'it.does.now'); | ||
expect(visConfig.get('this.does.not.exist')).to.be('it.does.now'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const SCALE_MODES = { | ||
NORMAL: 'normal', | ||
PERCENTAGE: 'percentage', | ||
WIGGLE: 'wiggle', | ||
SILHOUETTE: 'silhouette', | ||
ALL: ['normal', 'percentage', 'wiggle', 'silhouette'] | ||
}; | ||
|
||
export default SCALE_MODES; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters