mirror of
https://github.com/IT4Change/gradido.git
synced 2026-01-18 19:01:19 +00:00
get tests working, define default community in store with empty name and description
This commit is contained in:
parent
8a8cccd540
commit
2ac675287c
@ -1,20 +1,24 @@
|
|||||||
import { communityInfo } from '../graphql/queries'
|
import { communityInfo } from '../graphql/queries'
|
||||||
|
|
||||||
export const getCommunityInfo = {
|
export const getCommunityInfoMixin = {
|
||||||
beforeCreate() {
|
methods: {
|
||||||
if (!this.$store.state.community) {
|
getCommunityInfo() {
|
||||||
this.$apollo
|
if (this.$store.state.community.name === '') {
|
||||||
.query({
|
this.$apollo
|
||||||
query: communityInfo,
|
.query({
|
||||||
})
|
query: communityInfo,
|
||||||
.then((result) => {
|
})
|
||||||
// console.log('Got a community info: ', result.data.getCommunityInfo)
|
.then((result) => {
|
||||||
this.$store.commit('community', result.data.getCommunityInfo)
|
this.$store.commit('community', result.data.getCommunityInfo)
|
||||||
})
|
return result.data.getCommunityInfo
|
||||||
.catch((error) => {
|
})
|
||||||
// console.log('Got a error: ', error.message)
|
.catch((error) => {
|
||||||
this.$toasted.error(error.message)
|
this.$toasted.error(error.message)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getCommunityInfo()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,7 +89,10 @@ export const store = new Vuex.Store({
|
|||||||
token: null,
|
token: null,
|
||||||
coinanimation: true,
|
coinanimation: true,
|
||||||
newsletterState: null,
|
newsletterState: null,
|
||||||
community: null,
|
community: {
|
||||||
|
name: '',
|
||||||
|
description: '',
|
||||||
|
},
|
||||||
hasElopage: false,
|
hasElopage: false,
|
||||||
publisherId: null,
|
publisherId: null,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import { RouterLinkStub, mount } from '@vue/test-utils'
|
import { RouterLinkStub, mount } from '@vue/test-utils'
|
||||||
import flushPromises from 'flush-promises'
|
import flushPromises from 'flush-promises'
|
||||||
import Login from './Login'
|
import Login from './Login'
|
||||||
import { getCommunityInfo } from '../../mixin/getCommunityInfo'
|
import { getCommunityInfoMixin } from '../../mixin/getCommunityInfo'
|
||||||
|
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
localVue.mixin(getCommunityInfo)
|
localVue.mixin(getCommunityInfoMixin)
|
||||||
|
|
||||||
const apolloQueryMock = jest.fn().mockResolvedValue({
|
const apolloQueryMock = jest.fn().mockResolvedValue({
|
||||||
data: {
|
data: {
|
||||||
@ -19,11 +19,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({
|
|||||||
|
|
||||||
const toastErrorMock = jest.fn()
|
const toastErrorMock = jest.fn()
|
||||||
const mockStoreDispach = jest.fn()
|
const mockStoreDispach = jest.fn()
|
||||||
const mockStoreCommit = jest.fn((target, community) => {
|
const mockStoreCommit = jest.fn()
|
||||||
// console.log('mockStoreCommit', global.$store.state.community)
|
|
||||||
global.$store.state[target] = community
|
|
||||||
// console.log('mockStoreCommit', global.$store.state.community)
|
|
||||||
})
|
|
||||||
const mockRouterPush = jest.fn()
|
const mockRouterPush = jest.fn()
|
||||||
const spinnerHideMock = jest.fn()
|
const spinnerHideMock = jest.fn()
|
||||||
const spinnerMock = jest.fn(() => {
|
const spinnerMock = jest.fn(() => {
|
||||||
@ -32,21 +28,6 @@ const spinnerMock = jest.fn(() => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
global.$store = {
|
|
||||||
dispatch: mockStoreDispach,
|
|
||||||
commit: mockStoreCommit,
|
|
||||||
state: {
|
|
||||||
community: null,
|
|
||||||
publisherId: 12345,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
global.$toasted = {
|
|
||||||
error: toastErrorMock,
|
|
||||||
}
|
|
||||||
global.$apollo = {
|
|
||||||
query: apolloQueryMock,
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('Login', () => {
|
describe('Login', () => {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
@ -55,15 +36,29 @@ describe('Login', () => {
|
|||||||
locale: 'en',
|
locale: 'en',
|
||||||
},
|
},
|
||||||
$t: jest.fn((t) => t),
|
$t: jest.fn((t) => t),
|
||||||
$store: global.$store,
|
$store: {
|
||||||
|
dispatch: mockStoreDispach,
|
||||||
|
commit: mockStoreCommit,
|
||||||
|
state: {
|
||||||
|
community: {
|
||||||
|
name: '',
|
||||||
|
description: '',
|
||||||
|
},
|
||||||
|
publisherId: 12345,
|
||||||
|
},
|
||||||
|
},
|
||||||
$loading: {
|
$loading: {
|
||||||
show: spinnerMock,
|
show: spinnerMock,
|
||||||
},
|
},
|
||||||
$router: {
|
$router: {
|
||||||
push: mockRouterPush,
|
push: mockRouterPush,
|
||||||
},
|
},
|
||||||
$toasted: global.$toasted,
|
$toasted: {
|
||||||
$apollo: global.$apollo,
|
error: toastErrorMock,
|
||||||
|
},
|
||||||
|
$apollo: {
|
||||||
|
query: apolloQueryMock,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const stubs = {
|
const stubs = {
|
||||||
@ -112,12 +107,23 @@ describe('Login', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('Community Data', () => {
|
describe('Community Data', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
mocks.$store.state.community = {
|
||||||
|
name: 'Gradido Entwicklung',
|
||||||
|
url: 'http://localhost/vue/',
|
||||||
|
registerUrl: 'http://localhost/vue/register',
|
||||||
|
description: 'Die lokale Entwicklungsumgebung von Gradido.',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
it('has a Community name', () => {
|
it('has a Community name', () => {
|
||||||
expect(wrapper.find('.test-communitydata b').text()).toBe('test12')
|
expect(wrapper.find('.test-communitydata b').text()).toBe('Gradido Entwicklung')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has a Community description', () => {
|
it('has a Community description', () => {
|
||||||
expect(wrapper.find('.test-communitydata p').text()).toBe('test community 12')
|
expect(wrapper.find('.test-communitydata p').text()).toBe(
|
||||||
|
'Die lokale Entwicklungsumgebung von Gradido.',
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -63,7 +63,7 @@
|
|||||||
import InputPassword from '../../components/Inputs/InputPassword'
|
import InputPassword from '../../components/Inputs/InputPassword'
|
||||||
import InputEmail from '../../components/Inputs/InputEmail'
|
import InputEmail from '../../components/Inputs/InputEmail'
|
||||||
import { login } from '../../graphql/queries'
|
import { login } from '../../graphql/queries'
|
||||||
import { getCommunityInfo } from '../../mixin/getCommunityInfo'
|
import { getCommunityInfoMixin } from '../../mixin/getCommunityInfo'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'login',
|
name: 'login',
|
||||||
@ -71,7 +71,7 @@ export default {
|
|||||||
InputPassword,
|
InputPassword,
|
||||||
InputEmail,
|
InputEmail,
|
||||||
},
|
},
|
||||||
mixins: [getCommunityInfo],
|
mixins: [getCommunityInfoMixin],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
form: {
|
form: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user