mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2025-05-18 12:02:53 +02:00
build(deps): update latest, fix issue with jest
This commit is contained in:
@ -36,7 +36,9 @@ export class GenerateChallengeCommand extends Command {
|
||||
)
|
||||
return 0
|
||||
} catch (error) {
|
||||
console.error(`${chalk.bold.red('Error:')} ${error.message as string}`)
|
||||
if (error instanceof Error) {
|
||||
console.error(`${chalk.bold.red('Error:')} ${error.message}`)
|
||||
}
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,9 @@ export class GenerateSolutionCommand extends Command {
|
||||
)
|
||||
return 0
|
||||
} catch (error) {
|
||||
console.error(`${chalk.bold.red('Error:')} ${error.message as string}`)
|
||||
if (error instanceof Error) {
|
||||
console.error(`${chalk.bold.red('Error:')} ${error.message}`)
|
||||
}
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,9 @@ export class RunTestCommand extends Command {
|
||||
console.log(successMessage)
|
||||
return 0
|
||||
} catch (error) {
|
||||
console.error(`\n${chalk.bold.red('Error:')} ${error.message as string}`)
|
||||
if (error instanceof Error) {
|
||||
console.error(`${chalk.bold.red('Error:')} ${error.message}`)
|
||||
}
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
@ -36,4 +36,55 @@ describe('utils/copyDirectory', () => {
|
||||
expect.arrayContaining(['default.png', 'index.ts', '.npmignore'])
|
||||
)
|
||||
})
|
||||
|
||||
it('copy the files and folders recursively', async () => {
|
||||
fsMock({
|
||||
'/source': {
|
||||
'random-folder': {
|
||||
'default.png': '',
|
||||
'second-random-folder': {
|
||||
'mycode.ts': ''
|
||||
}
|
||||
},
|
||||
'index.ts': '',
|
||||
'.npmignore': ''
|
||||
},
|
||||
'/destination': {}
|
||||
})
|
||||
|
||||
let destinationDirectoryContent = await fs.promises.readdir('/destination')
|
||||
let sourceDirectoryContent = await fs.promises.readdir('/source')
|
||||
let randomFolderContent = await fs.promises.readdir('/source/random-folder')
|
||||
let secondRandomFolderContent = await fs.promises.readdir(
|
||||
'/source/random-folder/second-random-folder'
|
||||
)
|
||||
expect(randomFolderContent.length).toEqual(2)
|
||||
expect(secondRandomFolderContent.length).toEqual(1)
|
||||
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')
|
||||
randomFolderContent = await fs.promises.readdir('/destination/random-folder')
|
||||
secondRandomFolderContent = await fs.promises.readdir(
|
||||
'/destination/random-folder/second-random-folder'
|
||||
)
|
||||
expect(destinationDirectoryContent.length).toEqual(3)
|
||||
expect(sourceDirectoryContent.length).toEqual(3)
|
||||
expect(destinationDirectoryContent).toEqual(
|
||||
expect.arrayContaining(['random-folder', 'index.ts', '.npmignore'])
|
||||
)
|
||||
expect(sourceDirectoryContent).toEqual(
|
||||
expect.arrayContaining(['random-folder', 'index.ts', '.npmignore'])
|
||||
)
|
||||
expect(randomFolderContent.length).toEqual(2)
|
||||
expect(secondRandomFolderContent.length).toEqual(1)
|
||||
expect(randomFolderContent).toEqual(
|
||||
expect.arrayContaining(['default.png', 'second-random-folder'])
|
||||
)
|
||||
expect(secondRandomFolderContent).toEqual(
|
||||
expect.arrayContaining(['mycode.ts'])
|
||||
)
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user