diff --git a/admin/src/components/UserTable.spec.js b/admin/src/components/UserTable.spec.js index a87497d81..3db0131a3 100644 --- a/admin/src/components/UserTable.spec.js +++ b/admin/src/components/UserTable.spec.js @@ -10,7 +10,7 @@ describe('UserTable', () => { type: 'Type', itemsUser: [], fieldsTable: [], - creation: {}, + creation: [], } const Wrapper = () => { diff --git a/admin/src/components/UserTable.vue b/admin/src/components/UserTable.vue index d382af138..265c2d12e 100644 --- a/admin/src/components/UserTable.vue +++ b/admin/src/components/UserTable.vue @@ -140,7 +140,7 @@ export default { default: '', }, creation: { - type: Object, + type: Array, required: false, }, }, diff --git a/admin/src/views/Creation.spec.js b/admin/src/views/Creation.spec.js new file mode 100644 index 000000000..02c2ed4ce --- /dev/null +++ b/admin/src/views/Creation.spec.js @@ -0,0 +1,59 @@ +import { mount } from '@vue/test-utils' +import Creation from './Creation.vue' + +const localVue = global.localVue + +const apolloQueryMock = jest.fn().mockResolvedValue({ + data: { + searchUsers: [ + { + firstName: 'Bibi', + lastName: 'Bloxberg', + email: 'bibi@bloxberg.de', + creation: [200, 400, 600], + }, + ], + }, +}) + +const toastErrorMock = jest.fn() + +const mocks = { + $apollo: { + query: apolloQueryMock, + }, + $toasted: { + error: toastErrorMock, + }, +} + +describe('Creation', () => { + let wrapper + + const Wrapper = () => { + return mount(Creation, { localVue, mocks }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('has a DIV element with the class.creation', () => { + expect(wrapper.find('div.creation').exists()).toBeTruthy() + }) + + describe('apollo returns error', () => { + beforeEach(() => { + apolloQueryMock.mockRejectedValue({ + message: 'Ouch', + }) + wrapper = Wrapper() + }) + + it('toasts an error message', () => { + expect(toastErrorMock).toBeCalledWith('Ouch') + }) + }) + }) +}) diff --git a/admin/src/views/Creation.vue b/admin/src/views/Creation.vue index df5bea28c..262d6299e 100644 --- a/admin/src/views/Creation.vue +++ b/admin/src/views/Creation.vue @@ -1,5 +1,5 @@