From 1e75ce74e2ffbbfa8334fe937d3b30a3cce6c20b Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Mon, 20 Nov 2017 00:09:46 -0800 Subject: [PATCH] :green_heart: --- app/stores/CollectionsStore.test.js | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/app/stores/CollectionsStore.test.js b/app/stores/CollectionsStore.test.js index 358f5bd5..67484384 100644 --- a/app/stores/CollectionsStore.test.js +++ b/app/stores/CollectionsStore.test.js @@ -4,29 +4,24 @@ import CollectionsStore from './CollectionsStore'; jest.mock('utils/ApiClient', () => ({ client: { post: {} }, })); -jest.mock('stores', () => ({ errors: {} })); +jest.mock('stores', () => ({ + errors: { add: jest.fn() } +})); describe('CollectionsStore', () => { let store; beforeEach(() => { - const cache = { - getItem: jest.fn(() => Promise.resolve()), - setItem: jest.fn(() => {}), - }; - - store = new CollectionsStore({ - teamId: 123, - cache, - }); + store = new CollectionsStore({}); }); - describe('#fetch', () => { + describe('#fetchAll', () => { test('should load stores', async () => { store.client = { post: jest.fn(() => ({ data: [ { + id: 123, name: 'New collection', }, ], @@ -35,20 +30,15 @@ describe('CollectionsStore', () => { await store.fetchAll(); - expect(store.client.post).toHaveBeenCalledWith('/collections.list', { - id: 123, - }); - expect(store.data.length).toBe(1); - expect(store.data[0].name).toBe('New collection'); + expect(store.client.post).toHaveBeenCalledWith('/collections.list'); + expect(store.data.size).toBe(1); + expect(store.data.values()[0].name).toBe('New collection'); }); test('should report errors', async () => { store.client = { post: jest.fn(() => Promise.reject), }; - store.errors = { - add: jest.fn(), - }; await store.fetchAll();