Commit b827a8fb authored by Frauke's avatar Frauke
Browse files

Added fileUtils test.

parent f382cce4
const expect = require('expect')
const fileUtils = require('../fileUtils')
const fs = require('fs')
const testString = 'This is a unit test string'
describe('File utils tests', () => {
after(() => {
fs.unlink('./server/test/test.txt', (err) => {
if (err) {
console.log(err)
return
}
fs.rmdir('./server/test', (err) => {
if (err) {
console.log(err)
}
})
})
})
it('should write a file to the filesystem', (done) => {
fileUtils.writeFile('test.txt', testString, './server/test').then(() => {
fs.access('./server/test/test.txt', (err) => {
if (err) {
return done(err)
}
done()
})
}).catch((err) => done(err))
})
it('should read a file from the filesystem', (done) => {
fileUtils.readFile('./server/test/test.txt').then((file) => {
expect(file).toBe(testString)
done()
}).catch((err) => done(err))
})
})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment