Skip to content

Commit

Permalink
Fix #92 browser prompt error
Browse files Browse the repository at this point in the history
Services default to null when no traces have been encountered. Instead,
use an empty array.

Signed-off-by: Joe Farro <joef@uber.com>
  • Loading branch information
tiffon committed Oct 27, 2017
1 parent 79d262d commit 53e9a92
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/reducers/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ function fetchStarted(state) {
}

function fetchServicesDone(state, { payload }) {
const services = payload.data;
if (Array.isArray(services)) {
services.sort(baseStringComparator);
}
const services = payload.data || [];
services.sort(baseStringComparator);
return { ...state, services, error: null, loading: false };
}

Expand Down
14 changes: 14 additions & 0 deletions src/reducers/services.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ function verifyInitialState() {
beforeEach(verifyInitialState);
afterEach(verifyInitialState);

it('#92 - ensures services is at least an empty array', () => {
const services = null;
const state = serviceReducer(initialState, {
type: `${fetchServices}_FULFILLED`,
payload: { data: services },
});
expect(state).toEqual({
services: [],
operationsForService: {},
loading: false,
error: null,
});
});

it('should handle a fetch services with loading state', () => {
const state = serviceReducer(initialState, {
type: `${fetchServices}_PENDING`,
Expand Down

0 comments on commit 53e9a92

Please sign in to comment.