1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2025-05-18 12:02:53 +02:00

test(cli): add commands/run/test

This commit is contained in:
Divlo
2021-12-06 17:18:14 +01:00
parent 249bb3a367
commit cffaa9ec40
8 changed files with 128 additions and 12 deletions

View File

@ -17,7 +17,7 @@ describe('utils/copyDirectory', () => {
'.npmignore': ''
},
'/destination': {}
})
}, { createCwd: false })
let destinationDirectoryContent = await fs.promises.readdir('/destination')
let sourceDirectoryContent = await fs.promises.readdir('/source')
@ -50,7 +50,7 @@ describe('utils/copyDirectory', () => {
'.npmignore': ''
},
'/destination': {}
})
}, { createCwd: false })
let destinationDirectoryContent = await fs.promises.readdir('/destination')
let sourceDirectoryContent = await fs.promises.readdir('/source')

View File

@ -13,19 +13,12 @@ describe('utils/createTemporaryEmptyFolder', () => {
fsMock.restore()
})
it('should create the temporary folder', async () => {
fsMock({})
expect(await isExistingPath(TEMPORARY_PATH)).toBeFalsy()
await createTemporaryEmptyFolder()
expect(await isExistingPath(TEMPORARY_PATH)).toBeTruthy()
})
it('should remove and create again the temporary folder', async () => {
fsMock({
[TEMPORARY_PATH]: {
'file.txt': ''
}
})
}, { createCwd: false })
expect(await isExistingPath(TEMPORARY_PATH)).toBeTruthy()
expect((await fs.promises.readdir(TEMPORARY_PATH)).length).toEqual(1)
await createTemporaryEmptyFolder()

View File

@ -10,14 +10,14 @@ describe('utils/isExistingFile', () => {
it('should return true if the file exists', async () => {
fsMock({
'/file.txt': ''
})
}, { createCwd: false })
expect(await isExistingPath('/file.txt')).toBeTruthy()
})
it("should return false if the file doesn't exists", async () => {
fsMock({
'/file.txt': ''
})
}, { createCwd: false })
expect(await isExistingPath('/randomfile.txt')).toBeFalsy()
})
})