Initial commit
This commit is contained in:
26
test/reducers/collections.spec.js
Normal file
26
test/reducers/collections.spec.js
Normal file
@ -0,0 +1,26 @@
|
||||
import expect from 'expect';
|
||||
import Immutable from 'immutable';
|
||||
import { configLoaded } from '../../src/actions/config';
|
||||
import { collections } from '../../src/reducers/collections';
|
||||
|
||||
describe('collections', () => {
|
||||
it('should handle an empty state', () => {
|
||||
expect(
|
||||
collections(undefined, {})
|
||||
).toEqual(
|
||||
null
|
||||
);
|
||||
});
|
||||
|
||||
it('should load the collections from the config', () => {
|
||||
expect(
|
||||
collections(undefined, configLoaded({collections: [
|
||||
{name: 'posts', folder: '_posts', fields: [{name: 'title', widget: 'string'}]}
|
||||
]}))
|
||||
).toEqual(
|
||||
Immutable.OrderedMap({
|
||||
posts: Immutable.fromJS({name: 'posts', folder: '_posts', fields: [{name: 'title', widget: 'string'}]})
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
38
test/reducers/config.spec.js
Normal file
38
test/reducers/config.spec.js
Normal file
@ -0,0 +1,38 @@
|
||||
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(
|
||||
config(Immutable.Map({'a': 'b', 'c': 'd'}), configLoaded({'a': 'changed', 'e': 'new'}))
|
||||
).toEqual(
|
||||
Immutable.Map({'a': 'changed', 'e': 'new'})
|
||||
);
|
||||
});
|
||||
|
||||
it('should mark the config as loading', () => {
|
||||
expect(
|
||||
config(undefined, configLoading())
|
||||
).toEqual(
|
||||
Immutable.Map({isFetching: true})
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle an error', () => {
|
||||
expect(
|
||||
config(Immutable.Map({isFetching: true}), configFailed(new Error('Config could not be loaded')))
|
||||
).toEqual(
|
||||
Immutable.Map({error: 'Error: Config could not be loaded'})
|
||||
);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user