2017-09-10 17:25:29 +05:30
|
|
|
import MonitoringStore from '~/monitoring/stores/monitoring_store';
|
2018-11-08 19:23:39 +05:30
|
|
|
import MonitoringMock, { deploymentData, environmentData } from './mock_data';
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
describe('MonitoringStore', () => {
|
|
|
|
const store = new MonitoringStore();
|
|
|
|
store.storeMetrics(MonitoringMock.data);
|
|
|
|
|
|
|
|
it('contains two groups that contains, one of which has two queries sorted by priority', () => {
|
|
|
|
expect(store.groups).toBeDefined();
|
|
|
|
expect(store.groups.length).toEqual(2);
|
|
|
|
expect(store.groups[0].metrics.length).toEqual(2);
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('gets the metrics count for every group', () => {
|
2019-02-15 15:39:39 +05:30
|
|
|
expect(store.getMetricsCount()).toEqual(3);
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('contains deployment data', () => {
|
2019-02-15 15:39:39 +05:30
|
|
|
store.storeDeploymentData(deploymentData);
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
expect(store.deploymentData).toBeDefined();
|
|
|
|
expect(store.deploymentData.length).toEqual(3);
|
|
|
|
expect(typeof store.deploymentData[0]).toEqual('object');
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
2018-11-08 19:23:39 +05:30
|
|
|
|
|
|
|
it('only stores environment data that contains deployments', () => {
|
2019-02-15 15:39:39 +05:30
|
|
|
store.storeEnvironmentsData(environmentData);
|
|
|
|
|
|
|
|
expect(store.environmentsData.length).toEqual(2);
|
|
|
|
});
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
it('removes the data if all the values from a query are not defined', () => {
|
|
|
|
expect(store.groups[1].metrics[0].queries[0].result.length).toEqual(0);
|
2018-11-08 19:23:39 +05:30
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|