macos-defaults/build/github/write-config.test.js

29 lines
715 B
JavaScript
Raw Normal View History

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) => {
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')