Browse Source

Merge pull request #313 from binki/remove-test-noglob

Test that remove() ignores glob characters.
ci/travis-osximage
JP Richardson 8 years ago
committed by GitHub
parent
commit
9d67a5df84
  1. 40
      lib/remove/__tests__/remove.test.js

40
lib/remove/__tests__/remove.test.js

@ -80,5 +80,45 @@ describe('remove', function () {
}, 25) }, 25)
fse.remove(file) fse.remove(file)
}) })
it('shouldn’t delete glob matches', function (done) {
var file = path.join(TEST_DIR, 'file?')
try {
fs.writeFileSync(file, 'hello')
} catch (ex) {
if (ex.code === 'ENOENT') {
return this.skip('Windows does not support filenames with ‘?’ or ‘*’ in them.')
}
throw ex
}
var wrongFile = path.join(TEST_DIR, 'file1')
fs.writeFileSync(wrongFile, 'yo')
assert(fs.existsSync(file))
assert(fs.existsSync(wrongFile))
fse.remove(file, function (err) {
assert.ifError(err)
assert(!fs.existsSync(file))
assert(fs.existsSync(wrongFile))
done()
})
})
it('shouldn’t delete glob matches when file doesn’t exist', function (done) {
var nonexistentFile = path.join(TEST_DIR, 'file?')
var wrongFile = path.join(TEST_DIR, 'file1')
fs.writeFileSync(wrongFile, 'yo')
assert(!fs.existsSync(nonexistentFile))
assert(fs.existsSync(wrongFile))
fse.remove(nonexistentFile, function (err) {
assert.ifError(err)
assert(!fs.existsSync(nonexistentFile))
assert(fs.existsSync(wrongFile))
done()
})
})
}) })
}) })

Loading…
Cancel
Save