diff --git a/webapp/components/ContentMenu/ContentMenu.spec.js b/webapp/components/ContentMenu/ContentMenu.spec.js index 850b12f65..b9e6ba3a9 100644 --- a/webapp/components/ContentMenu/ContentMenu.spec.js +++ b/webapp/components/ContentMenu/ContentMenu.spec.js @@ -32,12 +32,12 @@ describe('ContentMenu.vue', () => { }) describe('mount', () => { - mutations = { - 'modal/SET_OPEN': () => jest.fn(), - } + mutations = { + 'modal/SET_OPEN': () => jest.fn(), + } getters = { 'auth/isModerator': () => false, - 'auth/isAdmin': () => false, + 'auth/isAdmin': () => false, } const openContentMenu = (values = {}) => { @@ -48,7 +48,7 @@ describe('ContentMenu.vue', () => { }, mocks, store, - localVue, + localVue, }) menuToggle = wrapper.find('.content-menu-trigger') menuToggle.trigger('click') @@ -64,8 +64,8 @@ describe('ContentMenu.vue', () => { id: 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8', }, }) - let items = wrapper.findAll('.ds-menu-item') - openModalSpy = jest.spyOn(wrapper.vm, 'openModal') + let items = wrapper.findAll('.ds-menu-item') + openModalSpy = jest.spyOn(wrapper.vm, 'openModal') expect(items).toHaveLength(2) expect(items.at(0).text()).toBe('post.menu.edit') expect( @@ -81,8 +81,8 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/post-menu-delete') - items.at(1).trigger('click') - expect(openModalSpy).toHaveBeenCalledWith('delete') + items.at(1).trigger('click') + expect(openModalSpy).toHaveBeenCalledWith('delete') }) it('admin can pin unpinned post', () => { @@ -103,13 +103,15 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/post-menu-pin') - items.at(0).trigger('click') - expect(wrapper.emitted('pinPost')).toEqual([[ - { - id: 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8', - pinnedBy: null, - } - ]]) + items.at(0).trigger('click') + expect(wrapper.emitted('pinPost')).toEqual([ + [ + { + id: 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8', + pinnedBy: null, + }, + ], + ]) }) it('admin can unpin pinned post', () => { @@ -130,13 +132,15 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/post-menu-unpin') - items.at(0).trigger('click') - expect(wrapper.emitted('unpinPost')).toEqual([[ - { - id: 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8', - pinnedBy: 'someone', - } - ]]) + items.at(0).trigger('click') + expect(wrapper.emitted('unpinPost')).toEqual([ + [ + { + id: 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8', + pinnedBy: 'someone', + }, + ], + ]) }) }) @@ -149,7 +153,7 @@ describe('ContentMenu.vue', () => { id: 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8', }, }) - openModalSpy = jest.spyOn(wrapper.vm, 'openModal') + openModalSpy = jest.spyOn(wrapper.vm, 'openModal') let items = wrapper.findAll('.ds-menu-item') expect(items).toHaveLength(2) expect(items.at(0).text()).toBe('comment.menu.edit') @@ -159,8 +163,8 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/comment-menu-edit') - items.at(0).trigger('click') - expect(wrapper.emitted('showEditCommentMenu')).toEqual([[true]]) + items.at(0).trigger('click') + expect(wrapper.emitted('showEditCommentMenu')).toEqual([[true]]) expect(items.at(1).text()).toBe('comment.menu.delete') expect( items @@ -168,9 +172,8 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/comment-menu-delete') - items.at(1).trigger('click') - expect(openModalSpy).toHaveBeenCalledWith('delete') - + items.at(1).trigger('click') + expect(openModalSpy).toHaveBeenCalledWith('delete') }) }) @@ -185,7 +188,7 @@ describe('ContentMenu.vue', () => { id: 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8', }, }) - openModalSpy = jest.spyOn(wrapper.vm, 'openModal') + openModalSpy = jest.spyOn(wrapper.vm, 'openModal') let items = wrapper.findAll('.ds-menu-item') expect(items).toHaveLength(1) expect(items.at(0).text()).toBe('report.contribution.title') @@ -195,8 +198,8 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/report-contribution-title') - items.at(0).trigger('click') - expect(openModalSpy).toHaveBeenCalledWith('report') + items.at(0).trigger('click') + expect(openModalSpy).toHaveBeenCalledWith('report') }) it('anyone who is not owner can report comment', () => { @@ -207,7 +210,7 @@ describe('ContentMenu.vue', () => { id: 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8', }, }) - openModalSpy = jest.spyOn(wrapper.vm, 'openModal') + openModalSpy = jest.spyOn(wrapper.vm, 'openModal') let items = wrapper.findAll('.ds-menu-item') expect(items).toHaveLength(1) expect(items.at(0).text()).toBe('report.comment.title') @@ -217,8 +220,8 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/report-comment-title') - items.at(0).trigger('click') - expect(openModalSpy).toHaveBeenCalledWith('report') + items.at(0).trigger('click') + expect(openModalSpy).toHaveBeenCalledWith('report') }) it('other users can be reported', () => { @@ -229,7 +232,7 @@ describe('ContentMenu.vue', () => { id: 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8', }, }) - openModalSpy = jest.spyOn(wrapper.vm, 'openModal') + openModalSpy = jest.spyOn(wrapper.vm, 'openModal') let items = wrapper.findAll('.ds-menu-item') expect(items).toHaveLength(2) expect(items.at(0).text()).toBe('report.user.title') @@ -239,8 +242,8 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/report-user-title') - items.at(0).trigger('click') - expect(openModalSpy).toHaveBeenCalledWith('report') + items.at(0).trigger('click') + expect(openModalSpy).toHaveBeenCalledWith('report') }) it('other organizations can be reported', () => { @@ -251,7 +254,7 @@ describe('ContentMenu.vue', () => { id: 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8', }, }) - openModalSpy = jest.spyOn(wrapper.vm, 'openModal') + openModalSpy = jest.spyOn(wrapper.vm, 'openModal') let items = wrapper.findAll('.ds-menu-item') expect(items).toHaveLength(1) expect(items.at(0).text()).toBe('report.organization.title') @@ -261,8 +264,8 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/report-organization-title') - items.at(0).trigger('click') - expect(openModalSpy).toHaveBeenCalledWith('report') + items.at(0).trigger('click') + expect(openModalSpy).toHaveBeenCalledWith('report') }) }) @@ -278,7 +281,7 @@ describe('ContentMenu.vue', () => { disabled: false, }, }) - openModalSpy = jest.spyOn(wrapper.vm, 'openModal') + openModalSpy = jest.spyOn(wrapper.vm, 'openModal') let items = wrapper.findAll('.ds-menu-item') expect(items).toHaveLength(2) expect(items.at(1).text()).toBe('disable.contribution.title') @@ -288,8 +291,8 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/disable-contribution-title') - items.at(1).trigger('click') - expect(openModalSpy).toHaveBeenCalledWith('disable') + items.at(1).trigger('click') + expect(openModalSpy).toHaveBeenCalledWith('disable') }) it('moderator can disable comments', () => { @@ -301,7 +304,7 @@ describe('ContentMenu.vue', () => { disabled: false, }, }) - openModalSpy = jest.spyOn(wrapper.vm, 'openModal') + openModalSpy = jest.spyOn(wrapper.vm, 'openModal') let items = wrapper.findAll('.ds-menu-item') expect(items).toHaveLength(2) expect(items.at(1).text()).toBe('disable.comment.title') @@ -311,8 +314,8 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/disable-comment-title') - items.at(1).trigger('click') - expect(openModalSpy).toHaveBeenCalledWith('disable') + items.at(1).trigger('click') + expect(openModalSpy).toHaveBeenCalledWith('disable') }) it('moderator can disable users', () => { @@ -324,7 +327,7 @@ describe('ContentMenu.vue', () => { disabled: false, }, }) - openModalSpy = jest.spyOn(wrapper.vm, 'openModal') + openModalSpy = jest.spyOn(wrapper.vm, 'openModal') let items = wrapper.findAll('.ds-menu-item') expect(items).toHaveLength(3) expect(items.at(1).text()).toBe('disable.user.title') @@ -334,8 +337,8 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/disable-user-title') - items.at(1).trigger('click') - expect(openModalSpy).toHaveBeenCalledWith('disable') + items.at(1).trigger('click') + expect(openModalSpy).toHaveBeenCalledWith('disable') }) it('moderator can disable organizations', () => { @@ -347,7 +350,7 @@ describe('ContentMenu.vue', () => { disabled: false, }, }) - openModalSpy = jest.spyOn(wrapper.vm, 'openModal') + openModalSpy = jest.spyOn(wrapper.vm, 'openModal') let items = wrapper.findAll('.ds-menu-item') // for (var i = 0; i < items.length; i++) { console.log(items.at(i).html()) } expect(items).toHaveLength(2) @@ -358,8 +361,8 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/disable-organization-title') - items.at(1).trigger('click') - expect(openModalSpy).toHaveBeenCalledWith('disable') + items.at(1).trigger('click') + expect(openModalSpy).toHaveBeenCalledWith('disable') }) it('moderator can release posts', () => { @@ -371,7 +374,7 @@ describe('ContentMenu.vue', () => { disabled: true, }, }) - openModalSpy = jest.spyOn(wrapper.vm, 'openModal') + openModalSpy = jest.spyOn(wrapper.vm, 'openModal') let items = wrapper.findAll('.ds-menu-item') expect(items).toHaveLength(2) expect(items.at(1).text()).toBe('release.contribution.title') @@ -381,10 +384,8 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/release-contribution-title') - items.at(1).trigger('click') - expect(openModalSpy).toHaveBeenCalledWith( - 'release', 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8' - ) + items.at(1).trigger('click') + expect(openModalSpy).toHaveBeenCalledWith('release', 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8') }) it('moderator can release comments', () => { @@ -396,7 +397,7 @@ describe('ContentMenu.vue', () => { disabled: true, }, }) - openModalSpy = jest.spyOn(wrapper.vm, 'openModal') + openModalSpy = jest.spyOn(wrapper.vm, 'openModal') let items = wrapper.findAll('.ds-menu-item') expect(items).toHaveLength(2) expect(items.at(1).text()).toBe('release.comment.title') @@ -406,10 +407,8 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/release-comment-title') - items.at(1).trigger('click') - expect(openModalSpy).toHaveBeenCalledWith( - 'release', 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8' - ) + items.at(1).trigger('click') + expect(openModalSpy).toHaveBeenCalledWith('release', 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8') }) it('moderator can release users', () => { @@ -421,7 +420,7 @@ describe('ContentMenu.vue', () => { disabled: true, }, }) - openModalSpy = jest.spyOn(wrapper.vm, 'openModal') + openModalSpy = jest.spyOn(wrapper.vm, 'openModal') let items = wrapper.findAll('.ds-menu-item') expect(items).toHaveLength(3) expect(items.at(1).text()).toBe('release.user.title') @@ -431,10 +430,8 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/release-user-title') - items.at(1).trigger('click') - expect(openModalSpy).toHaveBeenCalledWith( - 'release', 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8' - ) + items.at(1).trigger('click') + expect(openModalSpy).toHaveBeenCalledWith('release', 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8') }) it('moderator can release organizations', () => { @@ -446,7 +443,7 @@ describe('ContentMenu.vue', () => { disabled: true, }, }) - openModalSpy = jest.spyOn(wrapper.vm, 'openModal') + openModalSpy = jest.spyOn(wrapper.vm, 'openModal') let items = wrapper.findAll('.ds-menu-item') expect(items).toHaveLength(2) expect(items.at(1).text()).toBe('release.organization.title') @@ -456,10 +453,8 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/release-organization-title') - items.at(1).trigger('click') - expect(openModalSpy).toHaveBeenCalledWith( - 'release', 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8' - ) + items.at(1).trigger('click') + expect(openModalSpy).toHaveBeenCalledWith('release', 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8') }) }) @@ -484,7 +479,7 @@ describe('ContentMenu.vue', () => { .attributes('to'), ).toBe('/settings') }) - + it('user can block other users', () => { const wrapper = openContentMenu({ isOwner: false, @@ -503,16 +498,18 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/settings-blocked-users-block') - items.at(1).trigger('click') - expect(wrapper.emitted('block')).toEqual([[ - { - id: 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8', - isBlocked: false, - } - ]]) + items.at(1).trigger('click') + expect(wrapper.emitted('block')).toEqual([ + [ + { + id: 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8', + isBlocked: false, + }, + ], + ]) }) - it('user can unblock blocked users', () => { + it('user can unblock blocked users', () => { const wrapper = openContentMenu({ isOwner: false, resourceType: 'user', @@ -531,13 +528,15 @@ describe('ContentMenu.vue', () => { .find('span.ds-menu-item-link') .attributes('to'), ).toBe('/settings-blocked-users-unblock') - items.at(1).trigger('click') - expect(wrapper.emitted('unblock')).toEqual([[ - { - id: 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8', - isBlocked: true, - } - ]]) + items.at(1).trigger('click') + expect(wrapper.emitted('unblock')).toEqual([ + [ + { + id: 'd23a4265-f5f7-4e17-9f86-85f714b4b9f8', + isBlocked: true, + }, + ], + ]) }) }) })