• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const assert = require('assert');
5const fs = require('fs');
6const path = require('path');
7
8const tmpdir = require('../common/tmpdir');
9tmpdir.refresh();
10
11{
12  const s = fs.createWriteStream(path.join(tmpdir.path, 'rw'));
13
14  s.close(common.mustCall());
15  s.close(common.mustCall());
16}
17
18{
19  const s = fs.createWriteStream(path.join(tmpdir.path, 'rw2'));
20
21  let emits = 0;
22  s.on('close', () => {
23    emits++;
24  });
25
26  s.close(common.mustCall(() => {
27    assert.strictEqual(emits, 1);
28    s.close(common.mustCall(() => {
29      assert.strictEqual(emits, 1);
30    }));
31    process.nextTick(() => {
32      s.close(common.mustCall(() => {
33        assert.strictEqual(emits, 1);
34      }));
35    });
36  }));
37}
38
39{
40  const s = fs.createWriteStream(path.join(tmpdir.path, 'rw'), {
41    autoClose: false
42  });
43
44  s.close(common.mustCall());
45  s.close(common.mustCall());
46}
47