Changed the logic so that we check if the queries have been send but does not check the result.

This commit is contained in:
elweyn 2021-11-05 12:32:45 +01:00
parent 80a5939551
commit 3d3a77a0ea

View File

@ -1,4 +1,5 @@
import { mount, RouterLinkStub } from '@vue/test-utils' import { mount, RouterLinkStub } from '@vue/test-utils'
import { communities, communityInfo } from '../../graphql/queries'
import RegisterSelectCommunity from './RegisterSelectCommunity' import RegisterSelectCommunity from './RegisterSelectCommunity'
const localVue = global.localVue const localVue = global.localVue
@ -92,16 +93,20 @@ describe('RegisterSelectCommunity', () => {
describe('mount', () => { describe('mount', () => {
beforeEach(() => { beforeEach(() => {
jest.clearAllMocks()
wrapper = Wrapper() wrapper = Wrapper()
}) })
// TODO: Tests so that resolved value order is followed it('calls the API to get the community info data', () => {
it('commits the community info to the store', () => { expect(apolloQueryMock).toBeCalledWith({
expect(mockStoreCommit).toBeCalledWith('community', { query: communityInfo,
name: 'test12', })
description: 'test community 12', })
url: 'http://test12.test12/',
registerUrl: 'http://test12.test12/vue/register', 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/', url: 'http://localhost/vue/',
registerUrl: 'http://localhost/vue/register-community', 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() wrapper = Wrapper()
}) })
it('does not call community info data when already filled', () => {
expect(apolloQueryMock).not.toBeCalledWith({
query: communityInfo,
})
})
it('has a Community name', () => { it('has a Community name', () => {
expect(wrapper.find('.card-body b').text()).toBe('Gradido Entwicklung') expect(wrapper.find('.card-body b').text()).toBe('Gradido Entwicklung')
}) })
@ -191,7 +164,7 @@ describe('RegisterSelectCommunity', () => {
describe('server returns data', () => { describe('server returns data', () => {
beforeEach(async () => { beforeEach(async () => {
wrapper = Wrapper() wrapper = Wrapper()
await wrapper.setProps({ await wrapper.setData({
communities: [ communities: [
{ {
id: 2, id: 2,
@ -226,7 +199,6 @@ describe('RegisterSelectCommunity', () => {
describe('server response is error', () => { describe('server response is error', () => {
beforeEach(() => { beforeEach(() => {
jest.clearAllMocks()
apolloQueryMock.mockRejectedValue({ apolloQueryMock.mockRejectedValue({
message: 'Wrong thing', message: 'Wrong thing',
}) })