mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Added in class checks and notification tests
This commit is contained in:
47
test/client/unit/specs/components/notifications.js
Normal file
47
test/client/unit/specs/components/notifications.js
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import { shallowMount, createLocalVue } from '@vue/test-utils';
|
||||||
|
import NotificationsComponent from 'client/components/notifications.vue';
|
||||||
|
import Store from 'client/libs/store';
|
||||||
|
|
||||||
|
const localVue = createLocalVue();
|
||||||
|
localVue.use(Store);
|
||||||
|
|
||||||
|
describe('Notifications', () => {
|
||||||
|
let store;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
store = new Store({
|
||||||
|
state: {
|
||||||
|
user: {
|
||||||
|
data: {
|
||||||
|
stats: {
|
||||||
|
lvl: 0,
|
||||||
|
},
|
||||||
|
flags: {},
|
||||||
|
preferences: {},
|
||||||
|
party: {
|
||||||
|
quest: {
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
'user:fetch': () => {},
|
||||||
|
'tasks:fetchUserTasks': () => {},
|
||||||
|
},
|
||||||
|
getters: {},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('set user has class computed prop', () => {
|
||||||
|
const wrapper = shallowMount(NotificationsComponent, { store, localVue });
|
||||||
|
|
||||||
|
expect(wrapper.vm.userHasClass).to.be.false;
|
||||||
|
|
||||||
|
store.state.user.data.stats.lvl = 10;
|
||||||
|
store.state.user.data.flags.classSelected = true;
|
||||||
|
store.state.user.data.preferences.disableClasses = false;
|
||||||
|
|
||||||
|
expect(wrapper.vm.userHasClass).to.be.true;
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import {shallow} from '@vue/test-utils';
|
import { shallow } from '@vue/test-utils';
|
||||||
|
|
||||||
import SidebarSection from 'client/components/sidebarSection.vue';
|
import SidebarSection from 'client/components/sidebarSection.vue';
|
||||||
|
|
||||||
@@ -51,4 +51,4 @@ describe('Sidebar Section', () => {
|
|||||||
|
|
||||||
expect(wrapper.find('.section-body').element.style.display).to.eq('none');
|
expect(wrapper.find('.section-body').element.style.display).to.eq('none');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -199,6 +199,9 @@ export default {
|
|||||||
userClassSelect () {
|
userClassSelect () {
|
||||||
return !this.user.flags.classSelected && this.user.stats.lvl >= 10;
|
return !this.user.flags.classSelected && this.user.stats.lvl >= 10;
|
||||||
},
|
},
|
||||||
|
userHasClass () {
|
||||||
|
return this.user.stats.lvl >= 10 && this.user.flags.classSelected && !this.user.preferences.disableClasses;
|
||||||
|
},
|
||||||
invitedToQuest () {
|
invitedToQuest () {
|
||||||
return this.user.party.quest.RSVPNeeded && !this.user.party.quest.completed;
|
return this.user.party.quest.RSVPNeeded && !this.user.party.quest.completed;
|
||||||
},
|
},
|
||||||
@@ -252,9 +255,9 @@ export default {
|
|||||||
if (after === before) return;
|
if (after === before) return;
|
||||||
if (!this.$store.getters['members:hasClass'](this.user)) return;
|
if (!this.$store.getters['members:hasClass'](this.user)) return;
|
||||||
|
|
||||||
let mana = after - before;
|
const mana = after - before;
|
||||||
|
|
||||||
if (this.user.stats.lvl < 10) return;
|
if (!this.userHasClass) return;
|
||||||
this.mp(mana);
|
this.mp(mana);
|
||||||
},
|
},
|
||||||
userLvl (after, before) {
|
userLvl (after, before) {
|
||||||
@@ -508,7 +511,7 @@ export default {
|
|||||||
case 'CRON':
|
case 'CRON':
|
||||||
if (notification.data) {
|
if (notification.data) {
|
||||||
if (notification.data.hp) this.hp(notification.data.hp, 'hp');
|
if (notification.data.hp) this.hp(notification.data.hp, 'hp');
|
||||||
if (notification.data.mp && this.user.stats.lvl >= 10) this.mp(notification.data.mp);
|
if (notification.data.mp && !this.userHasClass) this.mp(notification.data.mp);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'SCORED_TASK':
|
case 'SCORED_TASK':
|
||||||
|
|||||||
Reference in New Issue
Block a user