Skip to content

Commit 23a4fae

Browse files
committed
test: cover detailed file sizes in file status list
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 866c4dd commit 23a4fae

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

src/tests/components/FileStatusList.spec.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ describe('FileStatusList.vue', () => {
114114
const wrapper = createWrapper({ fileIds: [2, 1] })
115115
await wrapper.vm.loadFiles()
116116

117-
expect(axiosGetMock).toHaveBeenCalledWith('/ocs/v2.php/apps/libresign/api/v1/file/list', { timeout: 10000 })
117+
expect(axiosGetMock).toHaveBeenCalledWith('/ocs/v2.php/apps/libresign/api/v1/file/list', {
118+
params: { details: true },
119+
timeout: 10000,
120+
})
118121
expect(wrapper.vm.files.map((file: { id: number }) => file.id)).toEqual([2, 1])
119122
expect(wrapper.emitted('files-updated')?.at(-1)?.[0]).toEqual(wrapper.vm.files)
120123
})
@@ -160,4 +163,24 @@ describe('FileStatusList.vue', () => {
160163

161164
expect(wrapper.vm.updatePollingInterval).toBeNull()
162165
})
163-
})
166+
167+
it('renders the file size from the detailed payload', async () => {
168+
axiosGetMock.mockResolvedValueOnce({
169+
data: {
170+
ocs: {
171+
data: {
172+
data: [
173+
{ id: 1, uuid: 'a', name: 'contract-a.pdf', size: 2048, status: 1 },
174+
],
175+
},
176+
},
177+
},
178+
})
179+
180+
const wrapper = createWrapper({ fileIds: [1] })
181+
await wrapper.vm.loadFiles()
182+
await wrapper.vm.$nextTick()
183+
184+
expect(wrapper.find('.file-size').text()).toBe('2048B')
185+
})
186+
})

0 commit comments

Comments
 (0)