1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-23 00:22:19 +01:00

bugfix(metrics-poller) use size and not length for immutable array

This commit is contained in:
Ivar Conradi Østhus 2018-02-04 22:04:28 +01:00
parent 58dc5724b9
commit d5af3a736e
2 changed files with 5 additions and 4 deletions

View File

@ -1,4 +1,5 @@
import configureStore from 'redux-mock-store';
import { List } from 'immutable';
import thunkMiddleware from 'redux-thunk';
import fetchMock from 'fetch-mock';
import MetricsPoller from '../metrics-poller';
@ -12,7 +13,7 @@ describe('metrics-poller.js', () => {
});
test('Should not start poller before toggles are recieved', () => {
const initialState = { features: [{ name: 'test1' }] };
const initialState = { features: List.of([{ name: 'test1' }]) };
const store = mockStore(initialState);
fetchMock.getOnce('api/admin/metrics/feature-toggles', {
body: { lastHour: {}, lastMinute: {} },
@ -26,7 +27,7 @@ describe('metrics-poller.js', () => {
});
test('Should not start poller when state does not contain toggles', () => {
const initialState = { features: [] };
const initialState = { features: new List([]) };
const store = mockStore(initialState);
const metricsPoller = new MetricsPoller(store);
@ -46,7 +47,7 @@ describe('metrics-poller.js', () => {
headers: { 'content-type': 'application/json' },
});
const initialState = { features: [{ name: 'test1' }] };
const initialState = { features: List.of([{ name: 'test1' }]) };
const store = mockStore(initialState);
const metricsPoller = new MetricsPoller(store);

View File

@ -9,7 +9,7 @@ class MetricsPoller {
start() {
this.store.subscribe(() => {
const features = this.store.getState().features;
if (!this.timer && features.length > 0) {
if (!this.timer && features.size > 0) {
this.timer = setInterval(this.fetchMetrics.bind(this), 5000);
this.fetchMetrics();
}