]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(jest): replace mock with jest.spyOn
authorJohn Molakvoæ <skjnldsv@protonmail.com>
Tue, 20 Jun 2023 09:53:20 +0000 (11:53 +0200)
committerJohn Molakvoæ <skjnldsv@protonmail.com>
Wed, 21 Jun 2023 07:20:50 +0000 (09:20 +0200)
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
apps/files/src/actions/deleteAction.spec.ts
apps/files/src/actions/sidebarAction.spec.ts

index b36a2437cff6003895600dc7073ebadfff9018bf..1046fa6dad707b558350c3d6acbee2112605dd51 100644 (file)
@@ -161,8 +161,8 @@ describe('Delete action execute tests', () => {
        })
 
        test('Delete fails', async () => {
-               axios.delete = jest.fn(() => { throw new Error('Mock error') })
-               logger.error = jest.fn()
+               jest.spyOn(axios, 'delete').mockImplementation(() => { throw new Error('Mock error') })
+               jest.spyOn(logger, 'error').mockImplementation(() => jest.fn())
 
                const file = new File({
                        id: 1,
index 0381ab9e0c512b3553e8fd3e055bc295acdac690..cdf878459dbba07bc859645be79dba9627a34e30 100644 (file)
@@ -126,8 +126,8 @@ describe('Open sidebar action exec tests', () => {
 
        test('Open sidebar fails', async () => {
                const openMock = jest.fn(() => { throw new Error('Mock error') })
-               logger.error = jest.fn()
                window.OCA = { Files: { Sidebar: { open: openMock } } }
+               jest.spyOn(logger, 'error').mockImplementation(() => jest.fn())
 
                const file = new File({
                        id: 1,