From 7a40c5982b4353ea7610c10bb36e4463438882df Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 10 Mar 2020 12:38:00 +0100 Subject: [PATCH] FIX test --- lib/api/src/tests/stories.test.js | 37 +++++++++---------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/lib/api/src/tests/stories.test.js b/lib/api/src/tests/stories.test.js index ccfbc38e40b..5f9300b9640 100644 --- a/lib/api/src/tests/stories.test.js +++ b/lib/api/src/tests/stories.test.js @@ -516,11 +516,12 @@ describe('stories API', () => { it('changes args properly, per story when receiving STORY_ARGS_UPDATED', () => { const navigate = jest.fn(); const store = createMockStore(); + const api = new EventEmitter(); const { api: { setStories }, init, - } = initStories({ store, navigate, provider }); + } = initStories({ store, navigate, provider, fullAPI: api }); setStories({ 'a--1': { kind: 'a', name: '1', parameters, path: 'a--1', id: 'a--1', args: { a: 'b' } }, @@ -531,49 +532,31 @@ describe('stories API', () => { expect(initialStoriesHash['a--1'].args).toEqual({ a: 'b' }); expect(initialStoriesHash['b--1'].args).toEqual({ x: 'y' }); - const api = new EventEmitter(); - init({ api }); - + init(); api.emit(STORY_ARGS_UPDATED, 'a--1', { foo: 'bar' }); + const { storiesHash: changedStoriesHash } = store.getState(); - expect(changedStoriesHash['a--1']).toEqual({ - isLeaf: true, - parent: 'a', - kind: 'a', - name: '1', - parameters: {}, - path: 'a--1', - id: 'a--1', - args: { foo: 'bar' }, - }); - expect(changedStoriesHash['b--1']).toEqual({ - isLeaf: true, - parent: 'b', - kind: 'b', - name: '1', - parameters: {}, - path: 'b--1', - id: 'b--1', - args: { x: 'y' }, - }); + expect(changedStoriesHash['a--1'].args).toEqual({ foo: 'bar' }); + expect(changedStoriesHash['b--1'].args).toEqual({ x: 'y' }); }); it('updateStoryArgs emits UPDATE_STORY_ARGS and does not change anything', () => { const navigate = jest.fn(); + const emit = jest.fn(); + const on = jest.fn(); const store = createMockStore(); const { api: { setStories, updateStoryArgs }, init, - } = initStories({ store, navigate, provider }); + } = initStories({ store, navigate, provider, fullAPI: { emit, on } }); setStories({ 'a--1': { kind: 'a', name: '1', parameters, path: 'a--1', id: 'a--1', args: { a: 'b' } }, 'b--1': { kind: 'b', name: '1', parameters, path: 'b--1', id: 'b--1', args: { x: 'y' } }, }); - const emit = jest.fn(); - init({ api: { emit, on: jest.fn() } }); + init(); updateStoryArgs('a--1', { foo: 'bar' }); expect(emit).toHaveBeenCalledWith(UPDATE_STORY_ARGS, 'a--1', { foo: 'bar' });