diff options
Diffstat (limited to 'spec/frontend/whats_new/components/app_spec.js')
-rw-r--r-- | spec/frontend/whats_new/components/app_spec.js | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/spec/frontend/whats_new/components/app_spec.js b/spec/frontend/whats_new/components/app_spec.js index a349aad9f1c..59d05f68fdd 100644 --- a/spec/frontend/whats_new/components/app_spec.js +++ b/spec/frontend/whats_new/components/app_spec.js @@ -11,9 +11,11 @@ describe('App', () => { let store; let actions; let state; + let propsData = { features: '[ {"title":"Whats New Drawer"} ]' }; - beforeEach(() => { + const buildWrapper = () => { actions = { + openDrawer: jest.fn(), closeDrawer: jest.fn(), }; @@ -29,7 +31,12 @@ describe('App', () => { wrapper = mount(App, { localVue, store, + propsData, }); + }; + + beforeEach(() => { + buildWrapper(); }); afterEach(() => { @@ -42,6 +49,10 @@ describe('App', () => { expect(getDrawer().exists()).toBe(true); }); + it('dispatches openDrawer when mounted', () => { + expect(actions.openDrawer).toHaveBeenCalled(); + }); + it('dispatches closeDrawer when clicking close', () => { getDrawer().vm.$emit('close'); expect(actions.closeDrawer).toHaveBeenCalled(); @@ -54,4 +65,15 @@ describe('App', () => { expect(getDrawer().props('open')).toBe(openState); }); + + it('renders features when provided as props', () => { + expect(wrapper.find('h5').text()).toBe('Whats New Drawer'); + }); + + it('handles bad json argument gracefully', () => { + propsData = { features: 'this is not json' }; + buildWrapper(); + + expect(getDrawer().exists()).toBe(true); + }); }); |