forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for yaxis(), fix 1st yaxis losing settings. Closes elastic#97
- Loading branch information
Rashid Khan
committed
May 10, 2016
1 parent
4ddf80d
commit 1336024
Showing
4 changed files
with
72 additions
and
3 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
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,70 @@ | ||
const filename = require('path').basename(__filename); | ||
const fn = require(`../${filename}`); | ||
const Promise = require('bluebird'); | ||
|
||
const _ = require('lodash'); | ||
const expect = require('chai').expect; | ||
const invoke = require('./helpers/invoke_series_fn.js'); | ||
|
||
describe(filename, () => { | ||
|
||
let seriesList; | ||
beforeEach(() => { | ||
seriesList = require('./fixtures/seriesList.js')(); | ||
}); | ||
|
||
it('creates the yaxes array', () => { | ||
expect(seriesList._global).to.equal(undefined); | ||
return invoke(fn, [seriesList, 2]).then((r) => { | ||
expect(r.output.list[0]._global.yaxes).to.be.an('array'); | ||
}); | ||
}); | ||
|
||
it('puts odd numbers of the left, even on the right, by default', () => { | ||
return Promise.all([ | ||
invoke(fn, [seriesList, 1]).then((r) => { | ||
expect(r.output.list[0]._global.yaxes[0].position).to.equal('left'); | ||
}), | ||
invoke(fn, [seriesList, 2]).then((r) => { | ||
expect(r.output.list[0]._global.yaxes[1].position).to.equal('right'); | ||
}), | ||
invoke(fn, [seriesList, 3]).then((r) => { | ||
expect(r.output.list[0]._global.yaxes[2].position).to.equal('left'); | ||
}), | ||
]); | ||
}); | ||
|
||
it('it lets you override default positions', () => { | ||
return Promise.all([ | ||
invoke(fn, [seriesList, 1, null, null, 'right']).then((r) => { | ||
expect(r.output.list[0]._global.yaxes[0].position).to.equal('right'); | ||
}), | ||
invoke(fn, [seriesList, 2, null, null, 'right']).then((r) => { | ||
expect(r.output.list[0]._global.yaxes[1].position).to.equal('right'); | ||
}), | ||
]); | ||
}); | ||
|
||
it('sets the minimum (default: 0)', () => { | ||
return Promise.all([ | ||
invoke(fn, [seriesList, 1, null]).then((r) => { | ||
expect(r.output.list[0]._global.yaxes[0].min).to.equal(0); | ||
}), | ||
invoke(fn, [seriesList, 2, 10]).then((r) => { | ||
expect(r.output.list[0]._global.yaxes[1].min).to.equal(10); | ||
}), | ||
]); | ||
}); | ||
|
||
it('sets the max (default: no max)', () => { | ||
return Promise.all([ | ||
invoke(fn, [seriesList, 1, null]).then((r) => { | ||
expect(r.output.list[0]._global.yaxes[0].max).to.equal(undefined); | ||
}), | ||
invoke(fn, [seriesList, 2, null, 10]).then((r) => { | ||
expect(r.output.list[0]._global.yaxes[1].max).to.equal(10); | ||
}), | ||
]); | ||
}); | ||
|
||
}); |
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