mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2025-12-11 00:21:24 +01:00
feat: rewrite programming-challenges CLI (#3)
This commit is contained in:
38
cli/utils/__test__/copyDirectory.test.ts
Normal file
38
cli/utils/__test__/copyDirectory.test.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import fsMock from 'mock-fs'
|
||||
import fs from 'fs'
|
||||
|
||||
import { copyDirectory } from '../copyDirectory'
|
||||
|
||||
describe('utils/copyDirectory', () => {
|
||||
afterEach(async () => {
|
||||
fsMock.restore()
|
||||
})
|
||||
|
||||
it('copy the files', async () => {
|
||||
fsMock({
|
||||
'/source': {
|
||||
'default.png': '',
|
||||
'index.ts': '',
|
||||
'.npmignore': ''
|
||||
},
|
||||
'/destination': {}
|
||||
})
|
||||
|
||||
let destinationDirectoryContent = await fs.promises.readdir('/destination')
|
||||
let sourceDirectoryContent = await fs.promises.readdir('/source')
|
||||
expect(destinationDirectoryContent.length).toEqual(0)
|
||||
expect(sourceDirectoryContent.length).toEqual(3)
|
||||
|
||||
await copyDirectory('/source', '/destination')
|
||||
destinationDirectoryContent = await fs.promises.readdir('/destination')
|
||||
sourceDirectoryContent = await fs.promises.readdir('/source')
|
||||
expect(destinationDirectoryContent.length).toEqual(3)
|
||||
expect(sourceDirectoryContent.length).toEqual(3)
|
||||
expect(destinationDirectoryContent).toEqual(
|
||||
expect.arrayContaining(['default.png', 'index.ts', '.npmignore'])
|
||||
)
|
||||
expect(sourceDirectoryContent).toEqual(
|
||||
expect.arrayContaining(['default.png', 'index.ts', '.npmignore'])
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user