Browse Source

Fix remove() no-globbing tests to skip/pass on Windows

ci/travis-osximage
Nathan Phillip Brink 8 years ago
committed by Nathan Phillip Brink
parent
commit
efc2b76caf
No known key found for this signature in database GPG Key ID: 743A52E86BA81050
  1. 25
      lib/remove/__tests__/remove.test.js

25
lib/remove/__tests__/remove.test.js

@ -83,7 +83,14 @@ describe('remove', function () {
it('shouldn’t delete glob matches', function (done) {
var file = path.join(TEST_DIR, 'file?')
fs.writeFileSync(file, 'hello')
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')
@ -97,5 +104,21 @@ describe('remove', function () {
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