-
Notifications
You must be signed in to change notification settings - Fork 774
/
copy-gh-89.test.js
56 lines (44 loc) · 1.39 KB
/
copy-gh-89.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'use strict'
// relevant: https://github.com/jprichardson/node-fs-extra/issues/89
// come up with better file name
const fs = require('fs')
const os = require('os')
const fse = require(process.cwd())
const path = require('path')
const assert = require('assert')
/* global afterEach, beforeEach, describe, it */
describe('copy / gh #89', () => {
const TEST_DIR = path.join(os.tmpdir(), 'fs-extra', 'copy-gh-89')
beforeEach(done => {
fse.emptyDir(TEST_DIR, done)
})
afterEach(done => {
fse.remove(TEST_DIR, done)
})
it('should copy successfully', done => {
const A = path.join(TEST_DIR, 'A')
const B = path.join(TEST_DIR, 'B')
fs.mkdirSync(A)
fs.mkdirSync(B)
const one = path.join(A, 'one.txt')
const two = path.join(A, 'two.txt')
const three = path.join(B, 'three.txt')
const four = path.join(B, 'four.txt')
fs.writeFileSync(one, '1')
fs.writeFileSync(two, '2')
fs.writeFileSync(three, '3')
fs.writeFileSync(four, '4')
const C = path.join(TEST_DIR, 'C')
fse.copy(A, C, err => {
if (err) return done(err)
fse.copy(B, C, err => {
if (err) return done(err)
assert(fs.existsSync(path.join(C, 'one.txt')))
assert(fs.existsSync(path.join(C, 'two.txt')))
assert(fs.existsSync(path.join(C, 'three.txt')))
assert(fs.existsSync(path.join(C, 'four.txt')))
done()
})
})
})
})