index_pattern_specs.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. ///<amd-dependency path="test/specs/helpers" name="helpers" />
  2. import {describe, it, expect} from 'test/lib/common';
  3. import moment from 'moment';
  4. import {IndexPattern} from '../index_pattern';
  5. describe('IndexPattern', function() {
  6. describe('when getting index for today', function() {
  7. it('should return correct index name', function() {
  8. var pattern = new IndexPattern('[asd-]YYYY.MM.DD', 'Daily');
  9. var expected = 'asd-' + moment.utc().format('YYYY.MM.DD');
  10. expect(pattern.getIndexForToday()).to.be(expected);
  11. });
  12. });
  13. describe('when getting index list for time range', function() {
  14. describe('no interval', function() {
  15. it('should return correct index', function() {
  16. var pattern = new IndexPattern('my-metrics', null);
  17. var from = new Date(2015, 4, 30, 1, 2, 3);
  18. var to = new Date(2015, 5, 1, 12, 5 , 6);
  19. expect(pattern.getIndexList(from, to)).to.eql('my-metrics');
  20. });
  21. });
  22. describe('daily', function() {
  23. it('should return correct index list', function() {
  24. var pattern = new IndexPattern('[asd-]YYYY.MM.DD', 'Daily');
  25. var from = new Date(1432940523000);
  26. var to = new Date(1433153106000);
  27. var expected = [
  28. 'asd-2015.05.29',
  29. 'asd-2015.05.30',
  30. 'asd-2015.05.31',
  31. 'asd-2015.06.01',
  32. ];
  33. expect(pattern.getIndexList(from, to)).to.eql(expected);
  34. });
  35. });
  36. });
  37. });