This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
outline/app/stores/CollectionsStore.test.js
Tom Moor 47da3f2b9b Increase collections pagination limit (#561)
* I think this is the pragmatic solution for now. We can readdress later.
Also renamed fetchAll, to the more accurate fetchPage

* 💚
2018-02-04 12:30:35 -08:00

44 lines
1003 B
JavaScript

/* eslint-disable */
import CollectionsStore from './CollectionsStore';
const { client } = require('utils/ApiClient');
describe('CollectionsStore', () => {
let store;
beforeEach(() => {
store = new CollectionsStore({});
});
describe('#fetchPage', () => {
test('should load stores', async () => {
client.post = jest.fn(() => ({
data: [
{
id: 123,
name: 'New collection',
},
],
}))
await store.fetchPage();
expect(client.post).toHaveBeenCalledWith('/collections.list', undefined);
expect(store.data.size).toBe(1);
expect(store.data.values()[0].name).toBe('New collection');
});
test('should report errors', async () => {
client.post = jest.fn(() => Promise.reject())
store.errors = {
add: jest.fn(),
};
await store.fetchPage();
expect(store.errors.add).toHaveBeenCalledWith(
'Failed to load collections'
);
});
});
});