diff --git a/test/client/unit/specs/components/notifications.js b/test/client/unit/specs/components/notifications.js new file mode 100644 index 0000000000..9fede9de0b --- /dev/null +++ b/test/client/unit/specs/components/notifications.js @@ -0,0 +1,50 @@ +import { shallowMount, createLocalVue } from '@vue/test-utils'; +import NotificationsComponent from 'client/components/notifications.vue'; +import Store from 'client/libs/store'; +import { hasClass } from 'client/store/getters/members'; + +const localVue = createLocalVue(); +localVue.use(Store); + +describe.only('Notifications', () => { + let store; + + beforeEach(() => { + store = new Store({ + state: { + user: { + data: { + stats: { + lvl: 0, + }, + flags: {}, + preferences: {}, + party: { + quest: { + }, + }, + }, + }, + }, + actions: { + 'user:fetch': () => {}, + 'tasks:fetchUserTasks': () => {}, + }, + getters: { + 'members:hasClass': hasClass, + }, + }); + }); + + 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; + }); +}); diff --git a/test/client/unit/specs/components/sidebarSection.js b/test/client/unit/specs/components/sidebarSection.js index 23b651b7fc..f65bd87003 100644 --- a/test/client/unit/specs/components/sidebarSection.js +++ b/test/client/unit/specs/components/sidebarSection.js @@ -1,4 +1,4 @@ -import {shallow} from '@vue/test-utils'; +import { shallow } from '@vue/test-utils'; 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'); }); -}); \ No newline at end of file +}); diff --git a/website/client/components/notifications.vue b/website/client/components/notifications.vue index 1ef1d89e6b..96d097ac9f 100644 --- a/website/client/components/notifications.vue +++ b/website/client/components/notifications.vue @@ -198,6 +198,9 @@ export default { userClassSelect () { return !this.user.flags.classSelected && this.user.stats.lvl >= 10; }, + userHasClass () { + return this.$store.getters['members:hasClass'](this.user); + }, invitedToQuest () { return this.user.party.quest.RSVPNeeded && !this.user.party.quest.completed; }, @@ -244,9 +247,9 @@ export default { }, userMp (after, before) { if (after === before) return; - if (!this.$store.getters['members:hasClass'](this.user)) return; + if (!this.userHasClass) return; - let mana = after - before; + const mana = after - before; this.mp(mana); }, userLvl (after, before) { @@ -500,7 +503,7 @@ export default { case 'CRON': if (notification.data) { if (notification.data.hp) this.hp(notification.data.hp, 'hp'); - if (notification.data.mp) this.mp(notification.data.mp); + if (notification.data.mp && this.userHasClass) this.mp(notification.data.mp); } break; case 'SCORED_TASK':