Files
habitica/website/client/tests/unit/components/tasks/user.spec.js
tsukimi2 b0786647ed Bugfix challenge tags to normal tags after a challenge has ended/deleted (#12341)
* Fix bug in challenge tags not converted to normal tags after challenge ended/deleted

* Added test cases to test bug fix

* Set tag.challenge from String to Boolean in tag model schema

* Update existing test with tag challenge set to boolean instead of string

* Added migration file for converting tag challenge field from string to bool

* Implement suggestions from ilnt

* Use mongoose instead of Mock in migration

* Change from update to bulkwrite

* update users individually

Co-authored-by: Matteo Pagliazzi <matteopagliazzi@gmail.com>
2020-09-07 16:48:22 +02:00

66 lines
2.0 KiB
JavaScript

import { shallowMount, createLocalVue } from '@vue/test-utils';
import User from '@/components/tasks/user.vue';
import Store from '@/libs/store';
const localVue = createLocalVue();
localVue.use(Store);
describe('Tasks User', () => {
describe('Computed Properties', () => {
it('should render a challenge tag under challenge header in tag filter popup when the challenge is active', () => {
const activeChallengeTag = {
id: '1',
name: 'Challenge1',
challenge: true,
};
const state = {
user: {
data: {
tags: [activeChallengeTag],
},
},
};
const getters = {};
const store = new Store({ state, getters });
const wrapper = shallowMount(User, {
store,
localVue,
});
const computedTagsByType = wrapper.vm.tagsByType;
expect(computedTagsByType.challenges.tags.length).to.equal(1);
expect(computedTagsByType.challenges.tags[0].id).to.equal(activeChallengeTag.id);
expect(computedTagsByType.challenges.tags[0].name).to.equal(activeChallengeTag.name);
});
it('should render a challenge tag under normal tag header in tag filter popup when the challenge is no longer active', () => {
const inactiveChallengeTag = {
id: '1',
name: 'Challenge1',
challenge: false,
};
const state = {
user: {
data: {
tags: [inactiveChallengeTag],
},
},
};
const getters = {};
const store = new Store({ state, getters });
const wrapper = shallowMount(User, {
store,
localVue,
});
const computedTagsByType = wrapper.vm.tagsByType;
expect(computedTagsByType.challenges.tags.length).to.equal(0);
expect(computedTagsByType.user.tags.length).to.equal(1);
expect(computedTagsByType.user.tags[0].id).to.equal(inactiveChallengeTag.id);
expect(computedTagsByType.user.tags[0].name).to.equal(inactiveChallengeTag.name);
});
});
});