diff options
Diffstat (limited to 'spec/frontend/code_navigation/components/app_spec.js')
-rw-r--r-- | spec/frontend/code_navigation/components/app_spec.js | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/spec/frontend/code_navigation/components/app_spec.js b/spec/frontend/code_navigation/components/app_spec.js index 9306c15e676..0d7c0360e9b 100644 --- a/spec/frontend/code_navigation/components/app_spec.js +++ b/spec/frontend/code_navigation/components/app_spec.js @@ -5,13 +5,14 @@ import App from '~/code_navigation/components/app.vue'; import Popover from '~/code_navigation/components/popover.vue'; import createState from '~/code_navigation/store/state'; +const setInitialData = jest.fn(); const fetchData = jest.fn(); const showDefinition = jest.fn(); let wrapper; Vue.use(Vuex); -function factory(initialState = {}) { +function factory(initialState = {}, props = {}) { const store = new Vuex.Store({ state: { ...createState(), @@ -19,12 +20,13 @@ function factory(initialState = {}) { definitionPathPrefix: 'https://test.com/blob/main', }, actions: { + setInitialData, fetchData, showDefinition, }, }); - wrapper = shallowMount(App, { store }); + wrapper = shallowMount(App, { store, propsData: { ...props } }); } describe('Code navigation app component', () => { @@ -32,6 +34,19 @@ describe('Code navigation app component', () => { wrapper.destroy(); }); + it('sets initial data on mount if the correct props are passed', () => { + const codeNavigationPath = 'code/nav/path.js'; + const path = 'blob/path.js'; + const definitionPathPrefix = 'path/prefix'; + + factory({}, { codeNavigationPath, blobPath: path, pathPrefix: definitionPathPrefix }); + + expect(setInitialData).toHaveBeenCalledWith(expect.anything(), { + blobs: [{ codeNavigationPath, path }], + definitionPathPrefix, + }); + }); + it('fetches data on mount', () => { factory(); |