2015-09-28 09:28:19 -05:00
|
|
|
///<amd-dependency path="test/specs/helpers" name="helpers" />
|
|
|
|
|
2017-09-21 09:40:18 -05:00
|
|
|
import {describe, it, expect} from 'test/lib/common';
|
2015-12-21 09:00:58 -06:00
|
|
|
import moment from 'moment';
|
|
|
|
import IndexPattern from '../index_pattern';
|
2015-09-28 09:28:19 -05:00
|
|
|
|
|
|
|
describe('IndexPattern', function() {
|
|
|
|
|
2015-10-22 15:23:21 -05:00
|
|
|
describe('when getting index for today', function() {
|
2015-09-28 09:28:19 -05:00
|
|
|
it('should return correct index name', function() {
|
|
|
|
var pattern = new IndexPattern('[asd-]YYYY.MM.DD', 'Daily');
|
2015-10-22 15:58:31 -05:00
|
|
|
var expected = 'asd-' + moment.utc().format('YYYY.MM.DD');
|
2015-09-28 09:28:19 -05:00
|
|
|
|
|
|
|
expect(pattern.getIndexForToday()).to.be(expected);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when getting index list for time range', function() {
|
|
|
|
|
|
|
|
describe('no interval', function() {
|
|
|
|
it('should return correct index', function() {
|
|
|
|
var pattern = new IndexPattern('my-metrics');
|
|
|
|
var from = new Date(2015, 4, 30, 1, 2, 3);
|
|
|
|
var to = new Date(2015, 5, 1, 12, 5 , 6);
|
|
|
|
expect(pattern.getIndexList(from, to)).to.eql('my-metrics');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('daily', function() {
|
|
|
|
|
|
|
|
it('should return correct index list', function() {
|
|
|
|
var pattern = new IndexPattern('[asd-]YYYY.MM.DD', 'Daily');
|
|
|
|
var from = new Date(1432940523000);
|
|
|
|
var to = new Date(1433153106000);
|
|
|
|
|
|
|
|
var expected = [
|
|
|
|
'asd-2015.05.29',
|
|
|
|
'asd-2015.05.30',
|
|
|
|
'asd-2015.05.31',
|
|
|
|
'asd-2015.06.01',
|
|
|
|
];
|
|
|
|
|
|
|
|
expect(pattern.getIndexList(from, to)).to.eql(expected);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|