Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Apr 13, 2022
1 parent cb721f4 commit f55be50
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 458 deletions.
2 changes: 1 addition & 1 deletion packages/web-app-files/src/composables/upload/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './useUpload'
export * from './useUploadHelpers'

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mount, shallowMount, createLocalVue } from '@vue/test-utils'
import { mount, createLocalVue } from '@vue/test-utils'
import FileUpload from '../../../../../src/components/AppBar/Upload/FileUpload.vue'
import DesignSystem from 'owncloud-design-system'

Expand Down Expand Up @@ -32,28 +32,6 @@ describe('File Upload Component', () => {
expect(spyTriggerUpload).toHaveBeenCalledTimes(1)
expect(fileUploadInput.element.click).toHaveBeenCalledTimes(1)
})

describe('when file is selected for upload', () => {
const event = new Event('change')

it('should call "$_ocUpload_addFileToQueue"', async () => {
const wrapper = shallowMount(FileUpload, {
...getOptions(),
stubs: {
'oc-button': true,
'oc-icon': true
}
})
wrapper.vm.$_ocUpload_addFileToQueue = jest.fn()
await wrapper.vm.$forceUpdate()

const fileUploadInput = wrapper.find('#fileUploadInput')
await fileUploadInput.trigger('change')

expect(wrapper.vm.$_ocUpload_addFileToQueue).toHaveBeenCalledTimes(1)
expect(wrapper.vm.$_ocUpload_addFileToQueue).toHaveBeenCalledWith(event)
})
})
})
})

Expand All @@ -65,6 +43,12 @@ function getOptions() {
path: ''
},
localVue,
directives: { Translate }
directives: { Translate },
mocks: {
$uppyService: {
registerUploadInput: jest.fn(),
removeUploadInput: jest.fn()
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mount, shallowMount, createLocalVue } from '@vue/test-utils'
import { mount, createLocalVue } from '@vue/test-utils'
import FolderUpload from '@files/src/components/AppBar/Upload/FolderUpload.vue'
import DesignSystem from 'owncloud-design-system'

Expand All @@ -17,7 +17,13 @@ describe('FolderUpload Component', () => {
path: '/'
},
localVue,
directives: { translate: jest.fn() }
directives: { translate: jest.fn() },
mocks: {
$uppyService: {
registerUploadInput: jest.fn(),
removeUploadInput: jest.fn()
}
}
}

describe('when upload folder button is clicked', () => {
Expand All @@ -34,26 +40,5 @@ describe('FolderUpload Component', () => {
expect(spyTriggerUpload).toHaveBeenCalledTimes(1)
expect(spyClickUploadInput).toHaveBeenCalledTimes(1)
})

describe('when folder is selected for upload', () => {
it('should call "$_ocUpload_addDirectoryToQueue"', async () => {
const spyOcUploadAddDirectoryToQueue = jest
.spyOn(FolderUpload.mixins[0].methods, '$_ocUpload_addDirectoryToQueue')
.mockImplementation()
const wrapper = shallowMount(FolderUpload, {
...mountOptions,
stubs: {
'oc-icon': true,
'oc-resource-icon': true,
'oc-button': true
}
})

const folderUploadInput = wrapper.find(selector.uploadInput)
await folderUploadInput.trigger('change')

expect(spyOcUploadAddDirectoryToQueue).toHaveBeenCalledTimes(1)
})
})
})
})
37 changes: 0 additions & 37 deletions packages/web-app-files/tests/unit/mixins.spec.js

This file was deleted.

Loading

0 comments on commit f55be50

Please sign in to comment.