mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
remove files and code from coinanimation settings
This commit is contained in:
parent
425788ab97
commit
32f8e43c90
@ -1,127 +0,0 @@
|
|||||||
import { mount } from '@vue/test-utils'
|
|
||||||
import UserCoinAnimation from './UserCoinAnimation'
|
|
||||||
import { updateUserInfos } from '@/graphql/mutations'
|
|
||||||
|
|
||||||
import { toastErrorSpy, toastSuccessSpy } from '@test/testSetup'
|
|
||||||
|
|
||||||
const localVue = global.localVue
|
|
||||||
|
|
||||||
const mockAPIcall = jest.fn()
|
|
||||||
|
|
||||||
const storeCommitMock = jest.fn()
|
|
||||||
|
|
||||||
describe('UserCard_CoinAnimation', () => {
|
|
||||||
let wrapper
|
|
||||||
|
|
||||||
const mocks = {
|
|
||||||
$t: jest.fn((t) => t),
|
|
||||||
$store: {
|
|
||||||
state: {
|
|
||||||
language: 'de',
|
|
||||||
coinanimation: true,
|
|
||||||
},
|
|
||||||
commit: storeCommitMock,
|
|
||||||
},
|
|
||||||
$apollo: {
|
|
||||||
mutate: mockAPIcall,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
const Wrapper = () => {
|
|
||||||
return mount(UserCoinAnimation, { localVue, mocks })
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('mount', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
jest.clearAllMocks()
|
|
||||||
wrapper = Wrapper()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('renders the component', () => {
|
|
||||||
expect(wrapper.find('div#formusercoinanimation').exists()).toBeTruthy()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('has an edit BFormCheckbox switch', () => {
|
|
||||||
expect(wrapper.find('.Test-BFormCheckbox').exists()).toBeTruthy()
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('enable with success', () => {
|
|
||||||
beforeEach(async () => {
|
|
||||||
await wrapper.setData({ CoinAnimationStatus: false })
|
|
||||||
mockAPIcall.mockResolvedValue({
|
|
||||||
data: {
|
|
||||||
updateUserInfos: {
|
|
||||||
validValues: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
await wrapper.find('input').setChecked()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('calls the updateUserInfos mutation', () => {
|
|
||||||
expect(mockAPIcall).toBeCalledWith({
|
|
||||||
mutation: updateUserInfos,
|
|
||||||
variables: {
|
|
||||||
coinanimation: true,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('updates the store', () => {
|
|
||||||
expect(storeCommitMock).toBeCalledWith('coinanimation', true)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('toasts a success message', () => {
|
|
||||||
expect(toastSuccessSpy).toBeCalledWith('settings.coinanimation.True')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('disable with success', () => {
|
|
||||||
beforeEach(async () => {
|
|
||||||
await wrapper.setData({ CoinAnimationStatus: true })
|
|
||||||
mockAPIcall.mockResolvedValue({
|
|
||||||
data: {
|
|
||||||
updateUserInfos: {
|
|
||||||
validValues: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
await wrapper.find('input').setChecked(false)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('calls the subscribe mutation', () => {
|
|
||||||
expect(mockAPIcall).toBeCalledWith({
|
|
||||||
mutation: updateUserInfos,
|
|
||||||
variables: {
|
|
||||||
coinanimation: false,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it('updates the store', () => {
|
|
||||||
expect(storeCommitMock).toBeCalledWith('coinanimation', false)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('toasts a success message', () => {
|
|
||||||
expect(toastSuccessSpy).toBeCalledWith('settings.coinanimation.False')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('disable with server error', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
mockAPIcall.mockRejectedValue({
|
|
||||||
message: 'Ouch',
|
|
||||||
})
|
|
||||||
wrapper.find('input').trigger('change')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('resets the CoinAnimationStatus', () => {
|
|
||||||
expect(wrapper.vm.CoinAnimationStatus).toBeTruthy()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('toasts an error message', () => {
|
|
||||||
expect(toastErrorSpy).toBeCalledWith('Ouch')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@ -1,65 +0,0 @@
|
|||||||
<template>
|
|
||||||
<b-card
|
|
||||||
id="formusercoinanimation"
|
|
||||||
class="bg-transparent gradido-custom-background gradido-no-border-radius"
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
<b-row class="mb-3">
|
|
||||||
<b-col class="mb-2 col-12">
|
|
||||||
<small>
|
|
||||||
<b>{{ $t('settings.coinanimation.coinanimation') }}</b>
|
|
||||||
</small>
|
|
||||||
</b-col>
|
|
||||||
<b-col class="col-12">
|
|
||||||
<b-form-checkbox
|
|
||||||
class="Test-BFormCheckbox"
|
|
||||||
v-model="CoinAnimationStatus"
|
|
||||||
name="check-button"
|
|
||||||
switch
|
|
||||||
@change="onSubmit"
|
|
||||||
>
|
|
||||||
{{
|
|
||||||
CoinAnimationStatus
|
|
||||||
? $t('settings.coinanimation.True')
|
|
||||||
: $t('settings.coinanimation.False')
|
|
||||||
}}
|
|
||||||
</b-form-checkbox>
|
|
||||||
</b-col>
|
|
||||||
</b-row>
|
|
||||||
</div>
|
|
||||||
</b-card>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
import { updateUserInfos } from '@/graphql/mutations'
|
|
||||||
export default {
|
|
||||||
name: 'UserCoinAnimation',
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
CoinAnimationStatus: this.$store.state.coinanimation,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
async onSubmit() {
|
|
||||||
this.$apollo
|
|
||||||
.mutate({
|
|
||||||
mutation: updateUserInfos,
|
|
||||||
variables: {
|
|
||||||
coinanimation: this.CoinAnimationStatus,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
this.$store.commit('coinanimation', this.CoinAnimationStatus)
|
|
||||||
this.toastSuccess(
|
|
||||||
this.CoinAnimationStatus
|
|
||||||
? this.$t('settings.coinanimation.True')
|
|
||||||
: this.$t('settings.coinanimation.False'),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
this.CoinAnimationStatus = this.$store.state.coinanimation
|
|
||||||
this.toastError(error.message)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@ -31,7 +31,6 @@ export const updateUserInfos = gql`
|
|||||||
$password: String
|
$password: String
|
||||||
$passwordNew: String
|
$passwordNew: String
|
||||||
$locale: String
|
$locale: String
|
||||||
$coinanimation: Boolean
|
|
||||||
) {
|
) {
|
||||||
updateUserInfos(
|
updateUserInfos(
|
||||||
firstName: $firstName
|
firstName: $firstName
|
||||||
@ -39,7 +38,6 @@ export const updateUserInfos = gql`
|
|||||||
password: $password
|
password: $password
|
||||||
passwordNew: $passwordNew
|
passwordNew: $passwordNew
|
||||||
language: $locale
|
language: $locale
|
||||||
coinanimation: $coinanimation
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|||||||
@ -7,7 +7,6 @@ export const login = gql`
|
|||||||
firstName
|
firstName
|
||||||
lastName
|
lastName
|
||||||
language
|
language
|
||||||
coinanimation
|
|
||||||
klickTipp {
|
klickTipp {
|
||||||
newsletterState
|
newsletterState
|
||||||
}
|
}
|
||||||
@ -25,7 +24,6 @@ export const verifyLogin = gql`
|
|||||||
firstName
|
firstName
|
||||||
lastName
|
lastName
|
||||||
language
|
language
|
||||||
coinanimation
|
|
||||||
klickTipp {
|
klickTipp {
|
||||||
newsletterState
|
newsletterState
|
||||||
}
|
}
|
||||||
|
|||||||
@ -186,11 +186,6 @@
|
|||||||
"send_gdd": "GDD versenden",
|
"send_gdd": "GDD versenden",
|
||||||
"send_per_link": "GDD versenden per Link",
|
"send_per_link": "GDD versenden per Link",
|
||||||
"settings": {
|
"settings": {
|
||||||
"coinanimation": {
|
|
||||||
"coinanimation": "Münzanimation",
|
|
||||||
"False": "Münzanimation ausgeschaltet",
|
|
||||||
"True": "Münzanimation eingeschaltet"
|
|
||||||
},
|
|
||||||
"language": {
|
"language": {
|
||||||
"changeLanguage": "Sprache ändern",
|
"changeLanguage": "Sprache ändern",
|
||||||
"de": "Deutsch",
|
"de": "Deutsch",
|
||||||
|
|||||||
@ -186,11 +186,6 @@
|
|||||||
"send_gdd": "GDD send",
|
"send_gdd": "GDD send",
|
||||||
"send_per_link": "GDD send via link",
|
"send_per_link": "GDD send via link",
|
||||||
"settings": {
|
"settings": {
|
||||||
"coinanimation": {
|
|
||||||
"coinanimation": "Coin animation",
|
|
||||||
"False": "Coin animation disabled",
|
|
||||||
"True": "Coin animation enabled"
|
|
||||||
},
|
|
||||||
"language": {
|
"language": {
|
||||||
"changeLanguage": "Change language",
|
"changeLanguage": "Change language",
|
||||||
"de": "Deutsch",
|
"de": "Deutsch",
|
||||||
|
|||||||
@ -38,9 +38,5 @@ describe('Profile', () => {
|
|||||||
it('has a user change newsletter form', () => {
|
it('has a user change newsletter form', () => {
|
||||||
expect(wrapper.findComponent({ name: 'UserNewsletter' }).exists()).toBeTruthy()
|
expect(wrapper.findComponent({ name: 'UserNewsletter' }).exists()).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has a user change coin animation form', () => {
|
|
||||||
expect(wrapper.findComponent({ name: 'UserCoinAnimation' }).exists()).toBeTruthy()
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -8,8 +8,6 @@
|
|||||||
<user-language />
|
<user-language />
|
||||||
<hr />
|
<hr />
|
||||||
<user-newsletter />
|
<user-newsletter />
|
||||||
<hr />
|
|
||||||
<user-coin-animation />
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
@ -18,7 +16,6 @@ import UserData from '@/components/UserSettings/UserData.vue'
|
|||||||
import UserPassword from '@/components/UserSettings/UserPassword.vue'
|
import UserPassword from '@/components/UserSettings/UserPassword.vue'
|
||||||
import UserLanguage from '@/components/UserSettings/UserLanguage.vue'
|
import UserLanguage from '@/components/UserSettings/UserLanguage.vue'
|
||||||
import UserNewsletter from '@/components/UserSettings/UserNewsletter.vue'
|
import UserNewsletter from '@/components/UserSettings/UserNewsletter.vue'
|
||||||
import UserCoinAnimation from '@/components/UserSettings/UserCoinAnimation.vue'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Profile',
|
name: 'Profile',
|
||||||
@ -28,7 +25,6 @@ export default {
|
|||||||
UserPassword,
|
UserPassword,
|
||||||
UserLanguage,
|
UserLanguage,
|
||||||
UserNewsletter,
|
UserNewsletter,
|
||||||
UserCoinAnimation,
|
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
balance: { type: Number, default: 0 },
|
balance: { type: Number, default: 0 },
|
||||||
|
|||||||
@ -38,9 +38,6 @@ export const mutations = {
|
|||||||
isAdmin: (state, isAdmin) => {
|
isAdmin: (state, isAdmin) => {
|
||||||
state.isAdmin = !!isAdmin
|
state.isAdmin = !!isAdmin
|
||||||
},
|
},
|
||||||
coinanimation: (state, coinanimation) => {
|
|
||||||
state.coinanimation = coinanimation
|
|
||||||
},
|
|
||||||
hasElopage: (state, hasElopage) => {
|
hasElopage: (state, hasElopage) => {
|
||||||
state.hasElopage = hasElopage
|
state.hasElopage = hasElopage
|
||||||
},
|
},
|
||||||
@ -53,7 +50,6 @@ export const actions = {
|
|||||||
// commit('username', data.username)
|
// commit('username', data.username)
|
||||||
commit('firstName', data.firstName)
|
commit('firstName', data.firstName)
|
||||||
commit('lastName', data.lastName)
|
commit('lastName', data.lastName)
|
||||||
commit('coinanimation', data.coinanimation)
|
|
||||||
commit('newsletterState', data.klickTipp.newsletterState)
|
commit('newsletterState', data.klickTipp.newsletterState)
|
||||||
commit('hasElopage', data.hasElopage)
|
commit('hasElopage', data.hasElopage)
|
||||||
commit('publisherId', data.publisherId)
|
commit('publisherId', data.publisherId)
|
||||||
@ -65,7 +61,6 @@ export const actions = {
|
|||||||
// commit('username', '')
|
// commit('username', '')
|
||||||
commit('firstName', '')
|
commit('firstName', '')
|
||||||
commit('lastName', '')
|
commit('lastName', '')
|
||||||
commit('coinanimation', true)
|
|
||||||
commit('newsletterState', null)
|
commit('newsletterState', null)
|
||||||
commit('hasElopage', false)
|
commit('hasElopage', false)
|
||||||
commit('publisherId', null)
|
commit('publisherId', null)
|
||||||
@ -91,7 +86,6 @@ try {
|
|||||||
// username: '',
|
// username: '',
|
||||||
token: null,
|
token: null,
|
||||||
isAdmin: false,
|
isAdmin: false,
|
||||||
coinanimation: true,
|
|
||||||
newsletterState: null,
|
newsletterState: null,
|
||||||
hasElopage: false,
|
hasElopage: false,
|
||||||
publisherId: null,
|
publisherId: null,
|
||||||
|
|||||||
@ -20,7 +20,6 @@ const {
|
|||||||
token,
|
token,
|
||||||
firstName,
|
firstName,
|
||||||
lastName,
|
lastName,
|
||||||
coinanimation,
|
|
||||||
newsletterState,
|
newsletterState,
|
||||||
publisherId,
|
publisherId,
|
||||||
isAdmin,
|
isAdmin,
|
||||||
@ -78,14 +77,6 @@ describe('Vuex store', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('coinanimation', () => {
|
|
||||||
it('sets the state of coinanimation', () => {
|
|
||||||
const state = { coinanimation: true }
|
|
||||||
coinanimation(state, false)
|
|
||||||
expect(state.coinanimation).toEqual(false)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('newsletterState', () => {
|
describe('newsletterState', () => {
|
||||||
it('sets the state of newsletterState', () => {
|
it('sets the state of newsletterState', () => {
|
||||||
const state = { newsletterState: null }
|
const state = { newsletterState: null }
|
||||||
@ -134,7 +125,6 @@ describe('Vuex store', () => {
|
|||||||
language: 'de',
|
language: 'de',
|
||||||
firstName: 'Peter',
|
firstName: 'Peter',
|
||||||
lastName: 'Lustig',
|
lastName: 'Lustig',
|
||||||
coinanimation: false,
|
|
||||||
klickTipp: {
|
klickTipp: {
|
||||||
newsletterState: true,
|
newsletterState: true,
|
||||||
},
|
},
|
||||||
@ -145,7 +135,7 @@ describe('Vuex store', () => {
|
|||||||
|
|
||||||
it('calls nine commits', () => {
|
it('calls nine commits', () => {
|
||||||
login({ commit, state }, commitedData)
|
login({ commit, state }, commitedData)
|
||||||
expect(commit).toHaveBeenCalledTimes(9)
|
expect(commit).toHaveBeenCalledTimes(8)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('commits email', () => {
|
it('commits email', () => {
|
||||||
@ -168,29 +158,24 @@ describe('Vuex store', () => {
|
|||||||
expect(commit).toHaveBeenNthCalledWith(4, 'lastName', 'Lustig')
|
expect(commit).toHaveBeenNthCalledWith(4, 'lastName', 'Lustig')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('commits coinanimation', () => {
|
|
||||||
login({ commit, state }, commitedData)
|
|
||||||
expect(commit).toHaveBeenNthCalledWith(5, 'coinanimation', false)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('commits newsletterState', () => {
|
it('commits newsletterState', () => {
|
||||||
login({ commit, state }, commitedData)
|
login({ commit, state }, commitedData)
|
||||||
expect(commit).toHaveBeenNthCalledWith(6, 'newsletterState', true)
|
expect(commit).toHaveBeenNthCalledWith(5, 'newsletterState', true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('commits hasElopage', () => {
|
it('commits hasElopage', () => {
|
||||||
login({ commit, state }, commitedData)
|
login({ commit, state }, commitedData)
|
||||||
expect(commit).toHaveBeenNthCalledWith(7, 'hasElopage', false)
|
expect(commit).toHaveBeenNthCalledWith(6, 'hasElopage', false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('commits publisherId', () => {
|
it('commits publisherId', () => {
|
||||||
login({ commit, state }, commitedData)
|
login({ commit, state }, commitedData)
|
||||||
expect(commit).toHaveBeenNthCalledWith(8, 'publisherId', 1234)
|
expect(commit).toHaveBeenNthCalledWith(7, 'publisherId', 1234)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('commits isAdmin', () => {
|
it('commits isAdmin', () => {
|
||||||
login({ commit, state }, commitedData)
|
login({ commit, state }, commitedData)
|
||||||
expect(commit).toHaveBeenNthCalledWith(9, 'isAdmin', true)
|
expect(commit).toHaveBeenNthCalledWith(8, 'isAdmin', true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -200,7 +185,7 @@ describe('Vuex store', () => {
|
|||||||
|
|
||||||
it('calls nine commits', () => {
|
it('calls nine commits', () => {
|
||||||
logout({ commit, state })
|
logout({ commit, state })
|
||||||
expect(commit).toHaveBeenCalledTimes(9)
|
expect(commit).toHaveBeenCalledTimes(8)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('commits token', () => {
|
it('commits token', () => {
|
||||||
@ -223,29 +208,24 @@ describe('Vuex store', () => {
|
|||||||
expect(commit).toHaveBeenNthCalledWith(4, 'lastName', '')
|
expect(commit).toHaveBeenNthCalledWith(4, 'lastName', '')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('commits coinanimation', () => {
|
|
||||||
logout({ commit, state })
|
|
||||||
expect(commit).toHaveBeenNthCalledWith(5, 'coinanimation', true)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('commits newsletterState', () => {
|
it('commits newsletterState', () => {
|
||||||
logout({ commit, state })
|
logout({ commit, state })
|
||||||
expect(commit).toHaveBeenNthCalledWith(6, 'newsletterState', null)
|
expect(commit).toHaveBeenNthCalledWith(5, 'newsletterState', null)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('commits hasElopage', () => {
|
it('commits hasElopage', () => {
|
||||||
logout({ commit, state })
|
logout({ commit, state })
|
||||||
expect(commit).toHaveBeenNthCalledWith(7, 'hasElopage', false)
|
expect(commit).toHaveBeenNthCalledWith(6, 'hasElopage', false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('commits publisherId', () => {
|
it('commits publisherId', () => {
|
||||||
logout({ commit, state })
|
logout({ commit, state })
|
||||||
expect(commit).toHaveBeenNthCalledWith(8, 'publisherId', null)
|
expect(commit).toHaveBeenNthCalledWith(7, 'publisherId', null)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('commits isAdmin', () => {
|
it('commits isAdmin', () => {
|
||||||
logout({ commit, state })
|
logout({ commit, state })
|
||||||
expect(commit).toHaveBeenNthCalledWith(9, 'isAdmin', false)
|
expect(commit).toHaveBeenNthCalledWith(8, 'isAdmin', false)
|
||||||
})
|
})
|
||||||
|
|
||||||
// how to get this working?
|
// how to get this working?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user