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:
parent
58dc5724b9
commit
d5af3a736e
@ -1,4 +1,5 @@
|
|||||||
import configureStore from 'redux-mock-store';
|
import configureStore from 'redux-mock-store';
|
||||||
|
import { List } from 'immutable';
|
||||||
import thunkMiddleware from 'redux-thunk';
|
import thunkMiddleware from 'redux-thunk';
|
||||||
import fetchMock from 'fetch-mock';
|
import fetchMock from 'fetch-mock';
|
||||||
import MetricsPoller from '../metrics-poller';
|
import MetricsPoller from '../metrics-poller';
|
||||||
@ -12,7 +13,7 @@ describe('metrics-poller.js', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Should not start poller before toggles are recieved', () => {
|
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);
|
const store = mockStore(initialState);
|
||||||
fetchMock.getOnce('api/admin/metrics/feature-toggles', {
|
fetchMock.getOnce('api/admin/metrics/feature-toggles', {
|
||||||
body: { lastHour: {}, lastMinute: {} },
|
body: { lastHour: {}, lastMinute: {} },
|
||||||
@ -26,7 +27,7 @@ describe('metrics-poller.js', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Should not start poller when state does not contain toggles', () => {
|
test('Should not start poller when state does not contain toggles', () => {
|
||||||
const initialState = { features: [] };
|
const initialState = { features: new List([]) };
|
||||||
const store = mockStore(initialState);
|
const store = mockStore(initialState);
|
||||||
|
|
||||||
const metricsPoller = new MetricsPoller(store);
|
const metricsPoller = new MetricsPoller(store);
|
||||||
@ -46,7 +47,7 @@ describe('metrics-poller.js', () => {
|
|||||||
headers: { 'content-type': 'application/json' },
|
headers: { 'content-type': 'application/json' },
|
||||||
});
|
});
|
||||||
|
|
||||||
const initialState = { features: [{ name: 'test1' }] };
|
const initialState = { features: List.of([{ name: 'test1' }]) };
|
||||||
const store = mockStore(initialState);
|
const store = mockStore(initialState);
|
||||||
|
|
||||||
const metricsPoller = new MetricsPoller(store);
|
const metricsPoller = new MetricsPoller(store);
|
||||||
|
@ -9,7 +9,7 @@ class MetricsPoller {
|
|||||||
start() {
|
start() {
|
||||||
this.store.subscribe(() => {
|
this.store.subscribe(() => {
|
||||||
const features = this.store.getState().features;
|
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.timer = setInterval(this.fetchMetrics.bind(this), 5000);
|
||||||
this.fetchMetrics();
|
this.fetchMetrics();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user