mirror of
https://github.com/thangisme/notes.git
synced 2024-11-01 04:27:17 -04:00
23 lines
551 B
JavaScript
23 lines
551 B
JavaScript
|
|
||
|
var assert = require('assert');
|
||
|
var fs = require('fs');
|
||
|
var write = require('..');
|
||
|
|
||
|
describe('write-file-stdout', function () {
|
||
|
afterEach(function () {
|
||
|
if (fs.existsSync('fixture.txt')) fs.unlinkSync('fixture.txt');
|
||
|
});
|
||
|
|
||
|
it('should write to a file', function () {
|
||
|
write('fixture.txt', 'test');
|
||
|
assert.equal('test', fs.readFileSync('fixture.txt'));
|
||
|
});
|
||
|
|
||
|
it('should write to stdout', function (done) {
|
||
|
process.stdout.write = function (data) {
|
||
|
assert.equal('test', data);
|
||
|
done();
|
||
|
};
|
||
|
write('test');
|
||
|
});
|
||
|
});
|