macos-defaults/build/github/write-config.test.js
2020-09-26 20:24:54 +02:00

28 lines
711 B
JavaScript

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', () => {
copiedFiles.forEach(file => {
const fileContent = readFile(`${destinationPath}/${file}`)
expect(fileContent).toEqual(`copied:${templatesPath}/${file}`)
})
})
})
const callWriteConfig = () => writeConfig({}, templatesPath, destinationPath)
const readFile = file => fs.readFakeFileSync(file, 'utf8')