2016-02-25 00:45:56 -08:00
|
|
|
import expect from 'expect';
|
|
|
|
import Immutable from 'immutable';
|
|
|
|
import { configLoaded, configLoading, configFailed } from '../../src/actions/config';
|
|
|
|
import { config } from '../../src/reducers/config';
|
|
|
|
|
|
|
|
describe('config', () => {
|
|
|
|
it('should handle an empty state', () => {
|
|
|
|
expect(
|
|
|
|
config(undefined, {})
|
|
|
|
).toEqual(
|
|
|
|
null
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should handle an update', () => {
|
|
|
|
expect(
|
2016-09-13 15:30:58 +02:00
|
|
|
config(Immutable.Map({ 'a': 'b', 'c': 'd' }), configLoaded({ 'a': 'changed', 'e': 'new' }))
|
2016-02-25 00:45:56 -08:00
|
|
|
).toEqual(
|
2016-09-13 15:30:58 +02:00
|
|
|
Immutable.Map({ 'a': 'changed', 'e': 'new' })
|
2016-02-25 00:45:56 -08:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should mark the config as loading', () => {
|
|
|
|
expect(
|
|
|
|
config(undefined, configLoading())
|
|
|
|
).toEqual(
|
2016-09-13 15:30:58 +02:00
|
|
|
Immutable.Map({ isFetching: true })
|
2016-02-25 00:45:56 -08:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should handle an error', () => {
|
|
|
|
expect(
|
2016-09-13 15:30:58 +02:00
|
|
|
config(Immutable.Map({ isFetching: true }), configFailed(new Error('Config could not be loaded')))
|
2016-02-25 00:45:56 -08:00
|
|
|
).toEqual(
|
2016-09-13 15:30:58 +02:00
|
|
|
Immutable.Map({ error: 'Error: Config could not be loaded' })
|
2016-02-25 00:45:56 -08:00
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|