Skip to content

Commit

Permalink
Use strict assert in all tests (#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
manidlou authored and RyanZim committed Apr 19, 2018
1 parent da69c57 commit b02eea6
Show file tree
Hide file tree
Showing 41 changed files with 147 additions and 147 deletions.
2 changes: 1 addition & 1 deletion lib/copy-sync/__tests__/broken-symlink.test.js
Expand Up @@ -25,7 +25,7 @@ describe('copy-sync / broken symlink', () => {

it('should copy broken symlinks by default', () => {
assert.doesNotThrow(() => copySync(src, out))
assert.equal(fs.readlinkSync(path.join(out, 'broken-symlink')), path.join(src, 'does-not-exist'))
assert.strictEqual(fs.readlinkSync(path.join(out, 'broken-symlink')), path.join(src, 'does-not-exist'))
})

it('should throw an error when dereference=true', () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/copy-sync/__tests__/copy-sync-preserve-time.test.js
Expand Up @@ -52,7 +52,7 @@ describeIfPractical('copySync() - preserveTimestamps option', () => {
assert.strictEqual(toStat.atime.getTime(), utimes.timeRemoveMillis(fromStat.atime.getTime()))
}
} else {
assert.notEqual(toStat.mtime.getTime(), fromStat.mtime.getTime())
assert.notStrictEqual(toStat.mtime.getTime(), fromStat.mtime.getTime())
// the access time might actually be the same, so check only modification time
}
}
Expand Down
Expand Up @@ -26,7 +26,7 @@ describe('+ copySync() - prevent copying identical files and dirs', () => {
try {
fs.copySync(fileSrc, fileDest)
} catch (err) {
assert.equal(err.message, 'Source and destination must not be the same.')
assert.strictEqual(err.message, 'Source and destination must not be the same.')
}
})

Expand Down
8 changes: 4 additions & 4 deletions lib/copy-sync/__tests__/symlink.test.js
Expand Up @@ -30,8 +30,8 @@ describe('copy-sync / symlink', () => {
copySync(src, out)
})

assert.equal(fs.readlinkSync(path.join(out, 'file-symlink')), path.join(src, 'foo'))
assert.equal(fs.readlinkSync(path.join(out, 'dir-symlink')), path.join(src, 'dir'))
assert.strictEqual(fs.readlinkSync(path.join(out, 'file-symlink')), path.join(src, 'foo'))
assert.strictEqual(fs.readlinkSync(path.join(out, 'dir-symlink')), path.join(src, 'dir'))
})

it('copies file contents when dereference=true', () => {
Expand All @@ -43,11 +43,11 @@ describe('copy-sync / symlink', () => {

const fileSymlinkPath = path.join(out, 'file-symlink')
assert.ok(fs.lstatSync(fileSymlinkPath).isFile())
assert.equal(fs.readFileSync(fileSymlinkPath), 'foo contents')
assert.strictEqual(fs.readFileSync(fileSymlinkPath, 'utf8'), 'foo contents')

const dirSymlinkPath = path.join(out, 'dir-symlink')
assert.ok(fs.lstatSync(dirSymlinkPath).isDirectory())
assert.deepEqual(fs.readdirSync(dirSymlinkPath), ['bar'])
assert.deepStrictEqual(fs.readdirSync(dirSymlinkPath), ['bar'])
})
})

Expand Down
2 changes: 1 addition & 1 deletion lib/copy/__tests__/copy-preserve-time.test.js
Expand Up @@ -55,7 +55,7 @@ describeIfPractical('copy() - preserve timestamp', () => {
assert.strictEqual(toStat.atime.getTime(), utimes.timeRemoveMillis(fromStat.atime.getTime()))
}
} else {
assert.notEqual(toStat.mtime.getTime(), fromStat.mtime.getTime())
assert.notStrictEqual(toStat.mtime.getTime(), fromStat.mtime.getTime())
// the access time might actually be the same, so check only modification time
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/copy/__tests__/copy-prevent-copying-identical.test.js
Expand Up @@ -25,7 +25,7 @@ describe('+ copy() - prevent copying identical files and dirs', () => {
const fileDest = path.join(TEST_DIR, 'TEST_fs-extra_copy')

fs.copy(fileSrc, fileDest, err => {
assert.equal(err.message, 'Source and destination must not be the same.')
assert.strictEqual(err.message, 'Source and destination must not be the same.')
done()
})
})
Expand Down
2 changes: 1 addition & 1 deletion lib/copy/__tests__/copy.test.js
Expand Up @@ -25,7 +25,7 @@ describe('fs-extra', () => {
const fileSrc = path.join(TEST_DIR, 'TEST_fs-extra_copy')
const fileDest = path.join(TEST_DIR, 'TEST_fs-extra_copy')
fse.copy(fileSrc, fileDest, err => {
assert.equal(err.message, 'Source and destination must not be the same.')
assert.strictEqual(err.message, 'Source and destination must not be the same.')
done()
})
})
Expand Down
4 changes: 2 additions & 2 deletions lib/copy/__tests__/ncp/broken-symlink.test.js
Expand Up @@ -26,14 +26,14 @@ describe('ncp broken symlink', () => {
it('should copy broken symlinks by default', done => {
ncp(src, out, err => {
if (err) return done(err)
assert.equal(fs.readlinkSync(path.join(out, 'broken-symlink')), path.join(src, 'does-not-exist'))
assert.strictEqual(fs.readlinkSync(path.join(out, 'broken-symlink')), path.join(src, 'does-not-exist'))
done()
})
})

it('should return an error when dereference=true', done => {
ncp(src, out, {dereference: true}, err => {
assert.equal(err.code, 'ENOENT')
assert.strictEqual(err.code, 'ENOENT')
done()
})
})
Expand Down
2 changes: 1 addition & 1 deletion lib/copy/__tests__/ncp/ncp-error-perm.test.js
Expand Up @@ -43,7 +43,7 @@ describe('ncp / error / dest-permission', () => {

ncp(src, subdest, err => {
assert(err)
assert.equal(err.code, 'EACCES')
assert.strictEqual(err.code, 'EACCES')
done()
})
})
Expand Down
10 changes: 5 additions & 5 deletions lib/copy/__tests__/ncp/ncp.test.js
Expand Up @@ -24,7 +24,7 @@ describe('ncp', () => {
readDirFiles(src, 'utf8', (srcErr, srcFiles) => {
readDirFiles(out, 'utf8', (outErr, outFiles) => {
assert.ifError(srcErr)
assert.deepEqual(srcFiles, outFiles)
assert.deepStrictEqual(srcFiles, outFiles)
cb()
})
})
Expand Down Expand Up @@ -55,7 +55,7 @@ describe('ncp', () => {
filter(srcFiles)
readDirFiles(out, 'utf8', (outErr, outFiles) => {
assert.ifError(outErr)
assert.deepEqual(srcFiles, outFiles)
assert.deepStrictEqual(srcFiles, outFiles)
cb()
})
})
Expand Down Expand Up @@ -133,7 +133,7 @@ describe('ncp', () => {
it('file descriptors are passed correctly', cb => {
ncp(src, out, {
transform: (read, write, file) => {
assert.notEqual(file.name, undefined)
assert.notStrictEqual(file.name, undefined)
assert.strictEqual(typeof file.mode, 'number')
read.pipe(write)
}
Expand All @@ -158,7 +158,7 @@ describe('ncp', () => {
readDirFiles(src, 'utf8', (srcErr, srcFiles) => {
readDirFiles(out, 'utf8', (outErr, outFiles) => {
assert.ifError(srcErr)
assert.deepEqual(srcFiles, outFiles)
assert.deepStrictEqual(srcFiles, outFiles)
callback()
})
})
Expand All @@ -181,7 +181,7 @@ describe('ncp', () => {
}, 100)
} else {
// console.log('Total callback count is', totalCallbacks)
assert.equal(totalCallbacks, expected)
assert.strictEqual(totalCallbacks, expected)
done()
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/copy/__tests__/ncp/symlink.test.js
Expand Up @@ -27,8 +27,8 @@ describe('ncp / symlink', () => {
ncp(src, out, err => {
assert.ifError(err)

assert.equal(fs.readlinkSync(path.join(out, 'file-symlink')), path.join(src, 'foo'))
assert.equal(fs.readlinkSync(path.join(out, 'dir-symlink')), path.join(src, 'dir'))
assert.strictEqual(fs.readlinkSync(path.join(out, 'file-symlink')), path.join(src, 'foo'))
assert.strictEqual(fs.readlinkSync(path.join(out, 'dir-symlink')), path.join(src, 'dir'))

done()
})
Expand All @@ -40,11 +40,11 @@ describe('ncp / symlink', () => {

const fileSymlinkPath = path.join(out, 'file-symlink')
assert.ok(fs.lstatSync(fileSymlinkPath).isFile())
assert.equal(fs.readFileSync(fileSymlinkPath), 'foo contents')
assert.strictEqual(fs.readFileSync(fileSymlinkPath, 'utf8'), 'foo contents')

const dirSymlinkPath = path.join(out, 'dir-symlink')
assert.ok(fs.lstatSync(dirSymlinkPath).isDirectory())
assert.deepEqual(fs.readdirSync(dirSymlinkPath), ['bar'])
assert.deepStrictEqual(fs.readdirSync(dirSymlinkPath), ['bar'])

done()
})
Expand Down
12 changes: 6 additions & 6 deletions lib/empty/__tests__/empty-dir-sync.test.js
Expand Up @@ -24,22 +24,22 @@ describe('+ emptyDir()', () => {
describe('> when directory exists and contains items', () => {
it('should delete all of the items', () => {
// verify nothing
assert.equal(fs.readdirSync(TEST_DIR).length, 0)
assert.strictEqual(fs.readdirSync(TEST_DIR).length, 0)
fse.ensureFileSync(path.join(TEST_DIR, 'some-file'))
fse.ensureFileSync(path.join(TEST_DIR, 'some-file-2'))
fse.ensureDirSync(path.join(TEST_DIR, 'some-dir'))
assert.equal(fs.readdirSync(TEST_DIR).length, 3)
assert.strictEqual(fs.readdirSync(TEST_DIR).length, 3)

fse.emptyDirSync(TEST_DIR)
assert.equal(fs.readdirSync(TEST_DIR).length, 0)
assert.strictEqual(fs.readdirSync(TEST_DIR).length, 0)
})
})

describe('> when directory exists and contains no items', () => {
it('should do nothing', () => {
assert.equal(fs.readdirSync(TEST_DIR).length, 0)
assert.strictEqual(fs.readdirSync(TEST_DIR).length, 0)
fse.emptyDirSync(TEST_DIR)
assert.equal(fs.readdirSync(TEST_DIR).length, 0)
assert.strictEqual(fs.readdirSync(TEST_DIR).length, 0)
})
})

Expand All @@ -48,7 +48,7 @@ describe('+ emptyDir()', () => {
fse.removeSync(TEST_DIR)
assert(!fs.existsSync(TEST_DIR))
fse.emptyDirSync(TEST_DIR)
assert.equal(fs.readdirSync(TEST_DIR).length, 0)
assert.strictEqual(fs.readdirSync(TEST_DIR).length, 0)
})
})
})
12 changes: 6 additions & 6 deletions lib/empty/__tests__/empty-dir.test.js
Expand Up @@ -24,26 +24,26 @@ describe('+ emptyDir()', () => {
describe('> when directory exists and contains items', () => {
it('should delete all of the items', done => {
// verify nothing
assert.equal(fs.readdirSync(TEST_DIR).length, 0)
assert.strictEqual(fs.readdirSync(TEST_DIR).length, 0)
fse.ensureFileSync(path.join(TEST_DIR, 'some-file'))
fse.ensureFileSync(path.join(TEST_DIR, 'some-file-2'))
fse.ensureDirSync(path.join(TEST_DIR, 'some-dir'))
assert.equal(fs.readdirSync(TEST_DIR).length, 3)
assert.strictEqual(fs.readdirSync(TEST_DIR).length, 3)

fse.emptyDir(TEST_DIR, err => {
assert.ifError(err)
assert.equal(fs.readdirSync(TEST_DIR).length, 0)
assert.strictEqual(fs.readdirSync(TEST_DIR).length, 0)
done()
})
})
})

describe('> when directory exists and contains no items', () => {
it('should do nothing', done => {
assert.equal(fs.readdirSync(TEST_DIR).length, 0)
assert.strictEqual(fs.readdirSync(TEST_DIR).length, 0)
fse.emptyDir(TEST_DIR, err => {
assert.ifError(err)
assert.equal(fs.readdirSync(TEST_DIR).length, 0)
assert.strictEqual(fs.readdirSync(TEST_DIR).length, 0)
done()
})
})
Expand All @@ -55,7 +55,7 @@ describe('+ emptyDir()', () => {
assert(!fs.existsSync(TEST_DIR))
fse.emptyDir(TEST_DIR, err => {
assert.ifError(err)
assert.equal(fs.readdirSync(TEST_DIR).length, 0)
assert.strictEqual(fs.readdirSync(TEST_DIR).length, 0)
done()
})
})
Expand Down
4 changes: 2 additions & 2 deletions lib/ensure/__tests__/create.test.js
Expand Up @@ -38,7 +38,7 @@ describe('fs-extra', () => {
fs.writeFileSync(file, 'hello world')
fse.createFile(file, err => {
assert.ifError(err)
assert.equal(fs.readFileSync(file, 'utf8'), 'hello world')
assert.strictEqual(fs.readFileSync(file, 'utf8'), 'hello world')
done()
})
})
Expand All @@ -61,7 +61,7 @@ describe('fs-extra', () => {
fse.mkdirsSync(path.dirname(file))
fs.writeFileSync(file, 'hello world')
fse.createFileSync(file)
assert.equal(fs.readFileSync(file, 'utf8'), 'hello world')
assert.strictEqual(fs.readFileSync(file, 'utf8'), 'hello world')
})
})
})
Expand Down
4 changes: 2 additions & 2 deletions lib/ensure/__tests__/ensure.test.js
Expand Up @@ -53,7 +53,7 @@ describe('fs-extra', () => {

fse.ensureFile(p, err => {
assert(err)
assert.equal(err.code, 'EISDIR')
assert.strictEqual(err.code, 'EISDIR')
done()
})
})
Expand Down Expand Up @@ -91,7 +91,7 @@ describe('fs-extra', () => {
try {
fse.ensureFileSync(p)
} catch (e) {
assert.equal(e.code, 'EISDIR')
assert.strictEqual(e.code, 'EISDIR')
throw e
}
})
Expand Down
24 changes: 12 additions & 12 deletions lib/ensure/__tests__/link.test.js
Expand Up @@ -79,8 +79,8 @@ describe('fse-ensure-link', () => {
const dstContent = fs.readFileSync(dstpath, 'utf8')
const dstDirContents = fs.readdirSync(dstDir)

assert.equal(isSymlink, true)
assert.equal(srcContent, dstContent)
assert.strictEqual(isSymlink, true)
assert.strictEqual(srcContent, dstContent)
assert(dstDirContents.indexOf(dstBasename) >= 0)
return done()
}
Expand All @@ -96,10 +96,10 @@ describe('fse-ensure-link', () => {
it(`should return error when creating link file using src ${srcpath} and dst ${dstpath}`, done => {
const dstdirExistsBefore = fs.existsSync(path.dirname(dstpath))
const callback = err => {
assert.equal(err instanceof Error, true)
assert.strictEqual(err instanceof Error, true)
// ensure that directories aren't created if there's an error
const dstdirExistsAfter = fs.existsSync(path.dirname(dstpath))
assert.equal(dstdirExistsBefore, dstdirExistsAfter)
assert.strictEqual(dstdirExistsBefore, dstdirExistsAfter)
return done()
}
args.push(callback)
Expand All @@ -116,7 +116,7 @@ describe('fse-ensure-link', () => {
const callback = err => {
if (err) return done(err)
const destinationContentAfter = fs.readFileSync(dstpath, 'utf8')
assert.equal(destinationContentBefore, destinationContentAfter)
assert.strictEqual(destinationContentBefore, destinationContentAfter)
return done()
}
args.push(callback)
Expand All @@ -136,8 +136,8 @@ describe('fse-ensure-link', () => {
const isSymlink = fs.lstatSync(dstpath).isFile()
const dstContent = fs.readFileSync(dstpath, 'utf8')
const dstDirContents = fs.readdirSync(dstDir)
assert.equal(isSymlink, true)
assert.equal(srcContent, dstContent)
assert.strictEqual(isSymlink, true)
assert.strictEqual(srcContent, dstContent)
assert(dstDirContents.indexOf(dstBasename) >= 0)
})
}
Expand All @@ -155,9 +155,9 @@ describe('fse-ensure-link', () => {
} catch (e) {
err = e
}
assert.equal(err instanceof Error, true)
assert.strictEqual(err instanceof Error, true)
const dstdirExistsAfter = fs.existsSync(path.dirname(dstpath))
assert.equal(dstdirExistsBefore, dstdirExistsAfter)
assert.strictEqual(dstdirExistsBefore, dstdirExistsAfter)
})
}

Expand All @@ -169,7 +169,7 @@ describe('fse-ensure-link', () => {
const destinationContentBefore = fs.readFileSync(dstpath, 'utf8')
fn(...args)
const destinationContentAfter = fs.readFileSync(dstpath, 'utf8')
assert.equal(destinationContentBefore, destinationContentAfter)
assert.strictEqual(destinationContentBefore, destinationContentAfter)
})
}

Expand Down Expand Up @@ -213,8 +213,8 @@ describe('fse-ensure-link', () => {
const dstContent = fs.readFileSync(dstpath, 'utf8')
const dstDirContents = fs.readdirSync(dstDir)

assert.equal(isSymlink, true)
assert.equal(srcContent, dstContent)
assert.strictEqual(isSymlink, true)
assert.strictEqual(srcContent, dstContent)
assert(dstDirContents.indexOf(dstBasename) >= 0)
})
})
Expand Down
4 changes: 2 additions & 2 deletions lib/ensure/__tests__/symlink-paths.test.js
Expand Up @@ -67,7 +67,7 @@ describe('symlink-type', () => {
it(`should return '${JSON.stringify(expectedRelativePaths)}' when src '${args[0]}' and dst is '${args[1]}'`, done => {
const callback = (err, relativePaths) => {
if (err) done(err)
assert.deepEqual(relativePaths, expectedRelativePaths)
assert.deepStrictEqual(relativePaths, expectedRelativePaths)
done()
}
args.push(callback)
Expand All @@ -82,7 +82,7 @@ describe('symlink-type', () => {
const expectedRelativePaths = test[1]
it(`should return '${JSON.stringify(expectedRelativePaths)}' when src '${args[0]}' and dst is '${args[1]}'`, () => {
const relativePaths = symlinkPathsSync(...args)
assert.deepEqual(relativePaths, expectedRelativePaths)
assert.deepStrictEqual(relativePaths, expectedRelativePaths)
})
})
})
Expand Down

0 comments on commit b02eea6

Please sign in to comment.