forked from jprichardson/node-fs-extra
/
fs-integration.test.js
40 lines (32 loc) · 1.01 KB
/
fs-integration.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
'use strict'
const os = require('os')
const fs = require('fs')
const fse = require('../..')
const path = require('path')
const assert = require('assert')
/* global afterEach, beforeEach, describe, it */
describe('native fs', () => {
let TEST_DIR
beforeEach(done => {
TEST_DIR = path.join(os.tmpdir(), 'fs-extra', 'native-fs')
fse.emptyDir(TEST_DIR, done)
})
afterEach(done => fse.remove(TEST_DIR, done))
it('should use native fs methods', () => {
const file = path.join(TEST_DIR, 'write.txt')
fse.writeFileSync(file, 'hello')
const data = fse.readFileSync(file, 'utf8')
assert.strictEqual(data, 'hello')
})
it('should have native fs constants', () => {
// Node.js v0.12 / IO.js
if ('F_OK' in fs) {
assert.strictEqual(fse.F_OK, fs.F_OK)
}
})
it('should have `fs.realpath*.native()` function', () => {
// Node.js v9.2.0
assert.strictEqual(fse.realpathSync.native, fs.realpathSync.native)
assert.strictEqual(fse.realpath.native, fs.realpath.native)
})
})