node-fs-extra/lib/remove/__tests__/remove-sync-dir.test.js
Ryan Zimmerman fd50986b4c
BREAKING: ESM support (#974)
* Remove process.cwd() trick from test files

* BREAKING: Switch from main to exports

* Add fs-extra/esm ESM named import module, with just fs-extra methods

Fixes #746
2022-11-28 13:50:33 -05:00

34 lines
847 B
JavaScript

'use strict'
const fs = require('fs')
const os = require('os')
const fse = require('../..')
const path = require('path')
const assert = require('assert')
/* global beforeEach, describe, it */
describe('remove/sync', () => {
let TEST_DIR
beforeEach(done => {
TEST_DIR = path.join(os.tmpdir(), 'fs-extra', 'remove-sync')
fse.emptyDir(TEST_DIR, done)
})
describe('+ removeSync()', () => {
it('should delete directories and files synchronously', () => {
assert(fs.existsSync(TEST_DIR))
fs.writeFileSync(path.join(TEST_DIR, 'somefile'), 'somedata')
fse.removeSync(TEST_DIR)
assert(!fs.existsSync(TEST_DIR))
})
it('should delete an empty directory synchronously', () => {
assert(fs.existsSync(TEST_DIR))
fse.removeSync(TEST_DIR)
assert(!fs.existsSync(TEST_DIR))
})
})
})