diff options
-rw-r--r-- | .eslintrc.js | 17 | ||||
-rw-r--r-- | jest.config.js | 4 | ||||
-rw-r--r-- | src/components/AvatarWrapper/AvatarWrapper.spec.js (renamed from tests/unit/AvatarWrapper.spec.js) | 26 | ||||
-rw-r--r-- | src/components/AvatarWrapper/AvatarWrapper.vue (renamed from src/components/AvatarWrapper.vue) | 2 | ||||
-rw-r--r-- | src/components/AvatarWrapper/AvatarWrapperSmall.vue (renamed from src/components/AvatarWrapperSmall.vue) | 2 | ||||
-rw-r--r-- | src/components/LeftSidebar/NewGroupConversation/SetContacts/ContactSelectionBubble/ContactSelectionBubble.vue | 2 | ||||
-rw-r--r-- | src/components/RightSidebar/Participants/ParticipantsList/Participant/Participant.vue | 2 | ||||
-rw-r--r-- | tests/unit/setup.js | 2 |
8 files changed, 37 insertions, 20 deletions
diff --git a/.eslintrc.js b/.eslintrc.js index 701f97a6e..bc3e64524 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,5 +1,20 @@ module.exports = { extends: [ 'nextcloud' - ] + ], + /** + * Allow jest syntax in the src folder + */ + env: { + jest: true + }, + /** + * Allow shallow import of @vue/test-utils in order to be able to use it in + * the src folder + */ + rules: { + "node/no-unpublished-import": ["error", { + "allowModules": ["@vue/test-utils"] + }] + } } diff --git a/jest.config.js b/jest.config.js index 026698f51..77eaf4b0a 100644 --- a/jest.config.js +++ b/jest.config.js @@ -22,5 +22,7 @@ module.exports = { preset: '@vue/cli-plugin-unit-jest/presets/no-babel', - setupFilesAfterEnv: ['<rootDir>/tests/unit/setup.js'] + // Allow tests in the src and in tests/unit folders + testMatch: ['<rootDir>/src/**/*.(spec|test).(ts|js)', '<rootDir>/tests/unit/**/*.(spec|test).(ts|js)'], + setupFilesAfterEnv: ['<rootDir>/tests/unit/setup.js'], } diff --git a/tests/unit/AvatarWrapper.spec.js b/src/components/AvatarWrapper/AvatarWrapper.spec.js index c04ba8ada..1a0d5a1e9 100644 --- a/tests/unit/AvatarWrapper.spec.js +++ b/src/components/AvatarWrapper/AvatarWrapper.spec.js @@ -1,41 +1,41 @@ import { shallowMount } from '@vue/test-utils' -import AvatarWrapper from '../../src/components/AvatarWrapper' +import AvatarWrapper from './AvatarWrapper' describe('AvatarWrapper.vue', () => { it('Renders user avatars properly', () => { const wrapper = shallowMount(AvatarWrapper, { - propsData: { + propsData: { id: 'mario', ource: 'users', - name: 'mario',} + name: 'mario' }, }) expect(wrapper.vm.iconClass).toBe('') - //Check that the first child is the avatar component + // Check that the first child is the avatar component expect(wrapper.element.firstChild.nodeName).toBe('AVATAR-STUB') expect(wrapper.props().size).toBe(32) }) it('Renders group icons properly', () => { const wrapper = shallowMount(AvatarWrapper, { - propsData: { + propsData: { id: '', source: 'groups', name: '', - } + }, }) expect(wrapper.vm.iconClass).toBe('icon-contacts') - //Check that the first child is a div + // Check that the first child is a div expect(wrapper.element.firstChild.nodeName).toBe('DIV') }) it('Renders email icons properly', () => { const wrapper = shallowMount(AvatarWrapper, { - propsData: { + propsData: { id: '', source: 'emails', - name: '' - } + name: '', + }, }) expect(wrapper.vm.iconClass).toBe('icon-mail') - //Check that the first child is a div + // Check that the first child is a div expect(wrapper.element.firstChild.nodeName).toBe('DIV') // proper size expect(wrapper.element.firstChild.classList).toContain('avatar-32px') @@ -43,10 +43,10 @@ describe('AvatarWrapper.vue', () => { it('Renders guests icons properly', () => { const wrapper = shallowMount(AvatarWrapper, { - propsData: { + propsData: { id: '', name: '', - size: '24' + size: '24', }, }) expect(wrapper.element.firstChild.classList).toContain('guest') diff --git a/src/components/AvatarWrapper.vue b/src/components/AvatarWrapper/AvatarWrapper.vue index d8dbec88e..1683e4df1 100644 --- a/src/components/AvatarWrapper.vue +++ b/src/components/AvatarWrapper/AvatarWrapper.vue @@ -112,7 +112,7 @@ export default { $avatar-size: 32px; height: $avatar-size; width: $avatar-size; - @import '../assets/avatar.scss'; + @import '../../assets/avatar.scss'; @include avatar-mixin($avatar-size); } diff --git a/src/components/AvatarWrapperSmall.vue b/src/components/AvatarWrapper/AvatarWrapperSmall.vue index a841f36bd..91b5da493 100644 --- a/src/components/AvatarWrapperSmall.vue +++ b/src/components/AvatarWrapper/AvatarWrapperSmall.vue @@ -112,7 +112,7 @@ export default { $avatar-size: 22px; height: $avatar-size; width: $avatar-size; - @import '../assets/avatar.scss'; + @import '../../assets/avatar.scss'; @include avatar-mixin($avatar-size); } diff --git a/src/components/LeftSidebar/NewGroupConversation/SetContacts/ContactSelectionBubble/ContactSelectionBubble.vue b/src/components/LeftSidebar/NewGroupConversation/SetContacts/ContactSelectionBubble/ContactSelectionBubble.vue index 57988b3af..a9dcfb8ce 100644 --- a/src/components/LeftSidebar/NewGroupConversation/SetContacts/ContactSelectionBubble/ContactSelectionBubble.vue +++ b/src/components/LeftSidebar/NewGroupConversation/SetContacts/ContactSelectionBubble/ContactSelectionBubble.vue @@ -38,7 +38,7 @@ </template> <script> -import AvatarWrapperSmall from '../../../../AvatarWrapperSmall' +import AvatarWrapperSmall from '../../../../AvatarWrapper/AvatarWrapperSmall' export default { name: 'ContactSelectionBubble', diff --git a/src/components/RightSidebar/Participants/ParticipantsList/Participant/Participant.vue b/src/components/RightSidebar/Participants/ParticipantsList/Participant/Participant.vue index 1f98c9216..7ee2e4774 100644 --- a/src/components/RightSidebar/Participants/ParticipantsList/Participant/Participant.vue +++ b/src/components/RightSidebar/Participants/ParticipantsList/Participant/Participant.vue @@ -64,7 +64,7 @@ import ActionButton from '@nextcloud/vue/dist/Components/ActionButton' import Actions from '@nextcloud/vue/dist/Components/Actions' import { CONVERSATION, PARTICIPANT } from '../../../../../constants' import isEqual from 'lodash/isEqual' -import AvatarWrapper from '../../../../AvatarWrapper' +import AvatarWrapper from '../../../../AvatarWrapper/AvatarWrapper' export default { name: 'Participant', diff --git a/tests/unit/setup.js b/tests/unit/setup.js index 77a7c4cc6..638fdc462 100644 --- a/tests/unit/setup.js +++ b/tests/unit/setup.js @@ -20,6 +20,6 @@ * */ global.OC = { - requestToken: '123' + requestToken: '123' } global.t = (app, text) => text |