mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
ensure that selected categories are resteted before toggling them to set saved categories
This commit is contained in:
parent
2c4f45ad70
commit
60627ffcf2
@ -73,8 +73,8 @@ describe('LoginForm', () => {
|
|||||||
describe('no categories saved', () => {
|
describe('no categories saved', () => {
|
||||||
it('resets the categories', async () => {
|
it('resets the categories', async () => {
|
||||||
await fillIn(Wrapper())
|
await fillIn(Wrapper())
|
||||||
expect(storeMocks.actions['auth/login']).toBeCalled()
|
|
||||||
expect(storeMocks.mutations['posts/RESET_CATEGORIES']).toBeCalled()
|
expect(storeMocks.mutations['posts/RESET_CATEGORIES']).toBeCalled()
|
||||||
|
expect(storeMocks.mutations['posts/TOGGLE_CATEGORY']).not.toBeCalled()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ describe('LoginForm', () => {
|
|||||||
it('sets the categories', async () => {
|
it('sets the categories', async () => {
|
||||||
authUserMock.mockReturnValue({ activeCategories: ['cat1', 'cat9', 'cat12'] })
|
authUserMock.mockReturnValue({ activeCategories: ['cat1', 'cat9', 'cat12'] })
|
||||||
await fillIn(Wrapper())
|
await fillIn(Wrapper())
|
||||||
expect(storeMocks.actions['auth/login']).toBeCalled()
|
expect(storeMocks.mutations['posts/RESET_CATEGORIES']).toBeCalled()
|
||||||
expect(storeMocks.mutations['posts/TOGGLE_CATEGORY']).toBeCalledTimes(3)
|
expect(storeMocks.mutations['posts/TOGGLE_CATEGORY']).toBeCalledTimes(3)
|
||||||
expect(storeMocks.mutations['posts/TOGGLE_CATEGORY']).toBeCalledWith({}, 'cat1')
|
expect(storeMocks.mutations['posts/TOGGLE_CATEGORY']).toBeCalledWith({}, 'cat1')
|
||||||
expect(storeMocks.mutations['posts/TOGGLE_CATEGORY']).toBeCalledWith({}, 'cat9')
|
expect(storeMocks.mutations['posts/TOGGLE_CATEGORY']).toBeCalledWith({}, 'cat9')
|
||||||
|
|||||||
@ -99,12 +99,11 @@ export default {
|
|||||||
try {
|
try {
|
||||||
await this.$store.dispatch('auth/login', { email, password })
|
await this.$store.dispatch('auth/login', { email, password })
|
||||||
if (this.currentUser && this.currentUser.activeCategories) {
|
if (this.currentUser && this.currentUser.activeCategories) {
|
||||||
|
this.resetCategories()
|
||||||
if (this.currentUser.activeCategories.length > 0) {
|
if (this.currentUser.activeCategories.length > 0) {
|
||||||
this.currentUser.activeCategories.forEach((categoryId) => {
|
this.currentUser.activeCategories.forEach((categoryId) => {
|
||||||
this.toggleCategory(categoryId)
|
this.toggleCategory(categoryId)
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
this.resetCategories()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.$toast.success(this.$t('login.success'))
|
this.$toast.success(this.$t('login.success'))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user