Skip to content

Commit 0787f3c

Browse files
committed
fix(test): spy on rm instead of rmdir
1 parent 9972a4f commit 0787f3c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

__tests__/swiftorg.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {MODULE_DIR} from '../src/const'
55

66
describe('swiftorg sync validation', () => {
77
const accessSpy = jest.spyOn(fs, 'access')
8-
const rmdirSpy = jest.spyOn(fs, 'rmdir').mockResolvedValue()
8+
const rmSpy = jest.spyOn(fs, 'rm').mockResolvedValue()
99
const execSpy = jest.spyOn(exec, 'exec')
1010

1111
it('tests latest sync', async () => {
@@ -14,7 +14,7 @@ describe('swiftorg sync validation', () => {
1414
fs.readdir = jest.fn().mockResolvedValue(['download'])
1515
const swiftorg = new Swiftorg(true)
1616
await swiftorg.update()
17-
expect(rmdirSpy).not.toHaveBeenCalled()
17+
expect(rmSpy).not.toHaveBeenCalled()
1818
expect(execSpy).toHaveBeenCalledTimes(2)
1919
const gitArgs = ['submodule', 'update', '--init', '--recursive', '--remote']
2020
expect(execSpy.mock.calls[1]).toStrictEqual([
@@ -30,7 +30,7 @@ describe('swiftorg sync validation', () => {
3030
fs.readdir = jest.fn().mockResolvedValue(['download'])
3131
const swiftorg = new Swiftorg(false)
3232
await swiftorg.update()
33-
expect(rmdirSpy).not.toHaveBeenCalled()
33+
expect(rmSpy).not.toHaveBeenCalled()
3434
expect(execSpy).toHaveBeenCalledTimes(2)
3535
const gitArgs = ['submodule', 'update', '--init']
3636
expect(execSpy.mock.calls[1]).toStrictEqual([
@@ -46,7 +46,7 @@ describe('swiftorg sync validation', () => {
4646
fs.readdir = jest.fn().mockResolvedValue([])
4747
const swiftorg = new Swiftorg(true)
4848
await swiftorg.update()
49-
expect(rmdirSpy).toHaveBeenCalled()
49+
expect(rmSpy).toHaveBeenCalled()
5050
expect(execSpy).toHaveBeenCalledTimes(3)
5151
})
5252

@@ -56,7 +56,7 @@ describe('swiftorg sync validation', () => {
5656
fs.readdir = jest.fn().mockResolvedValue([])
5757
const swiftorg = new Swiftorg(false)
5858
await swiftorg.update()
59-
expect(rmdirSpy).toHaveBeenCalled()
59+
expect(rmSpy).toHaveBeenCalled()
6060
expect(execSpy).toHaveBeenCalledTimes(4)
6161
})
6262

@@ -66,7 +66,7 @@ describe('swiftorg sync validation', () => {
6666
fs.readdir = jest.fn().mockResolvedValue([])
6767
const swiftorg = new Swiftorg(true)
6868
await swiftorg.update()
69-
expect(rmdirSpy).not.toHaveBeenCalled()
69+
expect(rmSpy).not.toHaveBeenCalled()
7070
expect(execSpy).toHaveBeenCalledTimes(3)
7171
})
7272

@@ -76,7 +76,7 @@ describe('swiftorg sync validation', () => {
7676
fs.readdir = jest.fn().mockResolvedValue([])
7777
const swiftorg = new Swiftorg(false)
7878
await swiftorg.update()
79-
expect(rmdirSpy).not.toHaveBeenCalled()
79+
expect(rmSpy).not.toHaveBeenCalled()
8080
expect(execSpy).toHaveBeenCalledTimes(4)
8181
})
8282

@@ -87,7 +87,7 @@ describe('swiftorg sync validation', () => {
8787
fs.readFile = jest.fn().mockResolvedValue('{}')
8888
const swiftorg = new Swiftorg(false)
8989
await swiftorg.update()
90-
expect(rmdirSpy).toHaveBeenCalled()
90+
expect(rmSpy).toHaveBeenCalled()
9191
expect(execSpy).toHaveBeenCalledTimes(3)
9292
})
9393

@@ -98,7 +98,7 @@ describe('swiftorg sync validation', () => {
9898
fs.readFile = jest.fn().mockResolvedValue('{}')
9999
const swiftorg = new Swiftorg(false)
100100
await swiftorg.update()
101-
expect(rmdirSpy).not.toHaveBeenCalled()
101+
expect(rmSpy).not.toHaveBeenCalled()
102102
expect(execSpy).toHaveBeenCalledTimes(3)
103103
})
104104
})

0 commit comments

Comments
 (0)