Test repo can now be used to list entries
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import expect from 'expect';
|
||||
import Immutable from 'immutable';
|
||||
import { Map, OrderedMap, fromJS } from 'immutable';
|
||||
import { configLoaded } from '../../src/actions/config';
|
||||
import { entriesLoading, entriesLoaded } from '../../src/actions/entries';
|
||||
import { collections } from '../../src/reducers/collections';
|
||||
|
||||
describe('collections', () => {
|
||||
@ -18,8 +19,35 @@ describe('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'}]})
|
||||
OrderedMap({
|
||||
posts: fromJS({name: 'posts', folder: '_posts', fields: [{name: 'title', widget: 'string'}]})
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('should mark entries as loading', () => {
|
||||
const state = OrderedMap({
|
||||
'posts': Map({name: 'posts'})
|
||||
});
|
||||
expect(
|
||||
collections(state, entriesLoading(Map({name: 'posts'})))
|
||||
).toEqual(
|
||||
OrderedMap({
|
||||
'posts': Map({name: 'posts', isFetching: true})
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle loaded entries', () => {
|
||||
const state = OrderedMap({
|
||||
'posts': Map({name: 'posts'})
|
||||
});
|
||||
const entries = [{slug: 'a', path: ''}, {slug: 'b', title: 'B'}];
|
||||
expect(
|
||||
collections(state, entriesLoaded(Map({name: 'posts'}), entries))
|
||||
).toEqual(
|
||||
OrderedMap({
|
||||
'posts': fromJS({name: 'posts', entries: entries})
|
||||
})
|
||||
);
|
||||
});
|
||||
|
Reference in New Issue
Block a user