2020-09-13 19:28:38 +00:00
|
|
|
const fs = require('fs')
|
|
|
|
jest.mock('fs')
|
|
|
|
|
|
|
|
const writeConfig = require('./write-config')
|
|
|
|
|
|
|
|
const templatesPath = 'templates'
|
|
|
|
const destinationPath = 'dist'
|
|
|
|
const copiedFiles = ['.gitmoji-changelogrc', 'license']
|
|
|
|
|
|
|
|
describe('write-config', () => {
|
|
|
|
afterEach(() => {
|
|
|
|
jest.clearAllMocks()
|
|
|
|
})
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
callWriteConfig()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should copy some static files', () => {
|
2020-11-27 12:45:16 +00:00
|
|
|
copiedFiles.forEach((file) => {
|
2020-09-13 19:28:38 +00:00
|
|
|
const fileContent = readFile(`${destinationPath}/${file}`)
|
|
|
|
expect(fileContent).toEqual(`copied:${templatesPath}/${file}`)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
const callWriteConfig = () => writeConfig({}, templatesPath, destinationPath)
|
2020-11-27 12:45:16 +00:00
|
|
|
const readFile = (file) => fs.readFakeFileSync(file, 'utf8')
|