summaryrefslogtreecommitdiff
path: root/node_modules/write-file-stdout/test/index.js
blob: b0c4ea21f6330c3548e27e5aab2804094cf144b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

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');
  });
});