diff --git a/frontend/src/views/Pages/RegisterSelectCommunity.spec.js b/frontend/src/views/Pages/RegisterSelectCommunity.spec.js index 8f334364a..0dc6be55a 100644 --- a/frontend/src/views/Pages/RegisterSelectCommunity.spec.js +++ b/frontend/src/views/Pages/RegisterSelectCommunity.spec.js @@ -1,4 +1,5 @@ import { mount, RouterLinkStub } from '@vue/test-utils' +import { communities, communityInfo } from '../../graphql/queries' import RegisterSelectCommunity from './RegisterSelectCommunity' const localVue = global.localVue @@ -92,16 +93,20 @@ describe('RegisterSelectCommunity', () => { describe('mount', () => { beforeEach(() => { + jest.clearAllMocks() wrapper = Wrapper() }) - // TODO: Tests so that resolved value order is followed - it('commits the community info to the store', () => { - expect(mockStoreCommit).toBeCalledWith('community', { - name: 'test12', - description: 'test community 12', - url: 'http://test12.test12/', - registerUrl: 'http://test12.test12/vue/register', + it('calls the API to get the community info data', () => { + expect(apolloQueryMock).toBeCalledWith({ + query: communityInfo, + }) + }) + + it('calls the API to get the communities data', () => { + expect(apolloQueryMock).toBeCalledWith({ + query: communities, + fetchPolicy: 'network-only', }) }) @@ -135,47 +140,15 @@ describe('RegisterSelectCommunity', () => { url: 'http://localhost/vue/', registerUrl: 'http://localhost/vue/register-community', } - apolloQueryMock - .mockResolvedValueOnce({ - data: { - getCommunityInfo: { - name: 'Gradido Entwicklung', - url: 'http://localhost/vue/', - registerUrl: 'http://localhost/vue/register', - description: 'Die lokale Entwicklungsumgebung von Gradido.', - }, - }, - }) - .mockResolvedValue({ - data: { - communities: [ - { - id: 1, - name: 'Gradido Entwicklung', - description: 'Die lokale Entwicklungsumgebung von Gradido.', - url: 'http://localhost/vue/', - registerUrl: 'http://localhost/vue/register-community', - }, - { - id: 2, - name: 'Gradido Staging', - description: 'Der Testserver der Gradido-Akademie.', - url: 'https://stage1.gradido.net/vue/', - registerUrl: 'https://stage1.gradido.net/vue/register-community', - }, - { - id: 3, - name: 'Gradido-Akademie', - description: 'Freies Institut für Wirtschaftsbionik.', - url: 'https://gradido.net', - registerUrl: 'https://gdd1.gradido.com/vue/register-community', - }, - ], - }, - }) wrapper = Wrapper() }) + it('does not call community info data when already filled', () => { + expect(apolloQueryMock).not.toBeCalledWith({ + query: communityInfo, + }) + }) + it('has a Community name', () => { expect(wrapper.find('.card-body b').text()).toBe('Gradido Entwicklung') }) @@ -191,7 +164,7 @@ describe('RegisterSelectCommunity', () => { describe('server returns data', () => { beforeEach(async () => { wrapper = Wrapper() - await wrapper.setProps({ + await wrapper.setData({ communities: [ { id: 2, @@ -226,7 +199,6 @@ describe('RegisterSelectCommunity', () => { describe('server response is error', () => { beforeEach(() => { - jest.clearAllMocks() apolloQueryMock.mockRejectedValue({ message: 'Wrong thing', })