Skip to content

Commit

Permalink
Make use of fixtures data
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranparajuli589 committed Jan 3, 2022
1 parent 218c4b7 commit 4ea40d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
9 changes: 9 additions & 0 deletions __fixtures__/sharedFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const files = {
mail_send: 0,
attributes: null,
tags: [],
indicators: [],
type: 'folder',
sharedWith: [
{
name: 'Quick action link',
Expand Down Expand Up @@ -65,6 +67,8 @@ const files = {
mail_send: 0,
attributes: null,
tags: [],
indicators: [],
type: 'folder',
sharedWith: [
{
name: 'Quick action link',
Expand Down Expand Up @@ -100,6 +104,8 @@ const files = {
mail_send: 0,
attributes: null,
tags: [],
indicators: [],
type: 'folder',
sharedWith: [
{
name: 'Quick action link',
Expand All @@ -122,6 +128,7 @@ const files = {
additional_info_owner: null,
additional_info_file_owner: null,
path: '/ownCloud Manual.pdf',
name: 'ownCloud Manual.pdf',
mimetype: 'text/plain',
storage_id: 'home::admin',
storage: 2,
Expand All @@ -136,6 +143,8 @@ const files = {
mail_send: 0,
attributes: null,
tags: ['_$!<Favorite>!$_'],
indicators: [],
type: 'file',
sharedWith: [
{
username: 'bob',
Expand Down
23 changes: 11 additions & 12 deletions packages/web-app-files/tests/unit/views/SharedWithOthers.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { mount, RouterLinkStub } from '@vue/test-utils'
import { getStore, localVue, createFile } from './views.setup.js'
import { getStore, localVue } from './views.setup.js'
import FileActions from '@files/src/mixins/fileActions.js'
import SharedWithOthers from '@files/src/views/SharedWithOthers.vue'
import fixtureSharedFiles from '@/__fixtures__/sharedFiles'

const resourcesList = fixtureSharedFiles.json().ocs.data

const $route = { params: { page: 1 } }
const $router = {
Expand Down Expand Up @@ -45,12 +48,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,14 +112,15 @@ describe('SharedWithOthers', () => {
const wrapper = getMountedWrapper({
paginationPage: 1,
paginationPages: 1,
paginatedResources: resourcesList
paginatedResources: resourcesList,
totalFilesCount: { files: 2, folders: 2 }
})
const listInfo = wrapper.find(listInfoStub)

expect(listInfo.exists()).toBeTruthy()
expect(listInfo.props()).toMatchObject({
files: 3,
folders: 0,
files: 2,
folders: 2,
size: null
})
stubs['resource-table'] = true
Expand Down Expand Up @@ -210,11 +208,12 @@ describe('SharedWithOthers', () => {
loading = false,
paginatedResources = [],
paginationPages = null,
paginationPage = null
paginationPage = null,
totalFilesCount = { files: 12, folders: 21 }
} = {}) {
const store = getStore({
selectedFiles,
totalFilesCount: { files: paginatedResources.length, folders: 0 }
totalFilesCount: totalFilesCount
})
const component = { ...SharedWithOthers, created: jest.fn() }
return mount(
Expand Down

0 comments on commit 4ea40d7

Please sign in to comment.