Skip to content

Commit

Permalink
check
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranparajuli589 committed Jan 26, 2022
1 parent 0499632 commit bd72638
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 98 deletions.
81 changes: 35 additions & 46 deletions packages/web-app-files/tests/unit/views/SharedWithOthers.spec.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { mount, RouterLinkStub } from '@vue/test-utils'
import { getStore, localVue, createFile } from './views.setup.js'
import { getStore, localVue, createFile, getRouter } from './views.setup.js'
import FileActions from '@files/src/mixins/fileActions.js'
import SharedWithOthers from '@files/src/views/SharedWithOthers.vue'
import SharedData from "@/__fixtures__/sharedFiles.js"

const $route = { params: { page: 1 } }
const $router = {
afterEach: jest.fn(),
currentRoute: {
query: {}
}
}
const resourcesList = SharedData.json().ocs.data

const stubs = {
'list-loader': true,
Expand All @@ -18,7 +13,12 @@ const stubs = {
'context-actions': true,
pagination: true,
'list-info': true,
'router-link': RouterLinkStub
'oc-resource': true,
'oc-checkbox': true,
'oc-avatars': true,
'oc-resource-size': true,
'oc-button': true,
'oc-drop': true
}

const listLoaderStub = 'list-loader-stub'
Expand Down Expand Up @@ -46,12 +46,6 @@ describe('SharedWithOthers', () => {
expect(wrapper.find(noContentStub).exists()).toBeTruthy()
})
describe('when length of paginated resources is greater than zero', () => {
const resourcesList = [
createFile({ id: '1234' }),
createFile({ id: '5896' }),
createFile({ id: '6789' })
]

const wrapper = getMountedWrapper({ paginatedResources: resourcesList })

it('should not show the no content message component', () => {
Expand Down Expand Up @@ -115,7 +109,7 @@ describe('SharedWithOthers', () => {

expect(listInfo.exists()).toBeTruthy()
expect(listInfo.props()).toMatchObject({
files: 3,
files: resourcesList.length,
folders: 0,
size: null
})
Expand Down Expand Up @@ -178,27 +172,6 @@ describe('SharedWithOthers', () => {
})
})

function mountOptions({ store, loading, paginatedResources, paginationPages, paginationPage }) {
return {
localVue,
store: store,
stubs,
mocks: {
$route,
$router
},
setup: () => ({
loadResourcesTask: {
isRunning: loading,
perform: jest.fn()
},
paginatedResources: paginatedResources,
paginationPages: paginationPages,
paginationPage: paginationPage
})
}
}

function getMountedWrapper({
selectedFiles = [],
loading = false,
Expand All @@ -210,16 +183,32 @@ describe('SharedWithOthers', () => {
selectedFiles,
totalFilesCount: { files: paginatedResources.length, folders: 0 }
})
const component = { ...SharedWithOthers, created: jest.fn() }
return mount(
component,
mountOptions({
store,
loading,
paginatedResources,
paginationPages,
paginationPage
const component = {
...SharedWithOthers,
created: jest.fn(),
mounted: jest.fn(),
setup: () => ({
loadResourcesTask: {
isRunning: loading,
perform: jest.fn()
},
paginatedResources: paginatedResources,
paginationPages: paginationPages,
paginationPage: paginationPage,
handleSort: jest.fn()
})
}
return mount(
component, {
localVue,
store: store,
stubs,
mocks: {
$route: {
name: 'some-route'
}
}
}
)
}
})
Loading

0 comments on commit bd72638

Please sign in to comment.