Skip to content

Commit

Permalink
Add tests for getIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasolson committed Apr 23, 2019
1 parent a65217c commit 56608ec
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/legacy/ui/public/index_patterns/__tests__/_index_pattern.js
Expand Up @@ -262,4 +262,39 @@ describe('index pattern', function () {
});
});
});

describe('getIndex', () => {
it('should return the title when there is no intervalName', () => {
expect(indexPattern.getIndex()).to.be(indexPattern.title);
});

it('should convert time-based intervals to wildcards', () => {
const oldTitle = indexPattern.title;
indexPattern.intervalName = 'daily';

indexPattern.title = '[logstash-]YYYY.MM.DD';
expect(indexPattern.getIndex()).to.be('logstash-*');

indexPattern.title = 'YYYY.MM.DD[-logstash]';
expect(indexPattern.getIndex()).to.be('*-logstash');

indexPattern.title = 'YYYY[-logstash-]YYYY.MM.DD';
expect(indexPattern.getIndex()).to.be('*-logstash-*');

indexPattern.title = 'YYYY[-logstash-]YYYY[-foo-]MM.DD';
expect(indexPattern.getIndex()).to.be('*-logstash-*-foo-*');

indexPattern.title = 'YYYY[-logstash-]YYYY[-foo-]MM.DD[-bar]';
expect(indexPattern.getIndex()).to.be('*-logstash-*-foo-*-bar');

indexPattern.title = '[logstash-]YYYY[-foo-]MM.DD[-bar]';
expect(indexPattern.getIndex()).to.be('logstash-*-foo-*-bar');

indexPattern.title = '[logstash]';
expect(indexPattern.getIndex()).to.be('logstash');

indexPattern.title = oldTitle;
delete indexPattern.intervalName;
});
});
});

0 comments on commit 56608ec

Please sign in to comment.