Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #665: Replaced var with let or const and added strict mode fs.a… #688

Merged
merged 3 commits into from Jan 31, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+21 −19
Diff settings

Always

Just for now

Next

Fixed #665: Replaced var with let or const and added strict mode fs.a…

…ccess.spec.js
  • Loading branch information...
ithompson4 committed Jan 28, 2019
commit 39de34b444eb621d9dd241f7889f02704bf926d1
@@ -1,12 +1,14 @@
var util = require('../lib/test-utils.js');
var expect = require('chai').expect;
'use strict';

const util = require('../lib/test-utils.js');
const expect = require('chai').expect;

describe('fs.access', function () {
beforeEach(util.setup);
afterEach(util.cleanup);

it('should expose access mode flags on fs and fs.constants', function() {
var fs = util.fs();
let fs = util.fs();
This conversation was marked as resolved by ithompson4

This comment has been minimized.

Copy link
@yuansheng1989

yuansheng1989 Jan 30, 2019

Contributor

use const is better, because it's not changed


// F_OK
expect(fs.F_OK).to.equal(0);
@@ -26,12 +28,12 @@ describe('fs.access', function () {
});

it('should be a function', function () {
var fs = util.fs();
let fs = util.fs();
This conversation was marked as resolved by ithompson4

This comment has been minimized.

Copy link
@yuansheng1989

yuansheng1989 Jan 30, 2019

Contributor

use const is better, because it's not changed

expect(typeof fs.access).to.equal('function');
});

it('should return an error if file does not exist', function (done) {
var fs = util.fs();
let fs = util.fs();
This conversation was marked as resolved by ithompson4

This comment has been minimized.

Copy link
@yuansheng1989

yuansheng1989 Jan 30, 2019

Contributor

use const is better, because it's not changed


fs.access('/tmp', fs.constants.F_OK, function (error) {
expect(error).to.exist;
@@ -41,8 +43,8 @@ describe('fs.access', function () {
});

it('should return no error if file does exist and mode = F_OK', function (done) {
var fs = util.fs();
var contents = 'This is a file.';
let fs = util.fs();

This comment has been minimized.

Copy link
@humphd

humphd Jan 31, 2019

Contributor

You can follow the same pattern as above, and use const here, since fs won't change during the scope of this function.

This comment has been minimized.

Copy link
@ithompson4

ithompson4 Jan 31, 2019

Author Contributor

I replaced all let statements with const and pushed another commit.

let contents = 'This is a file.';

fs.writeFile('/myfile', contents, function (error) {
if (error) throw error;
@@ -55,8 +57,8 @@ describe('fs.access', function () {
});

it('should return no error if file does exist and mode = R_OK', function (done) {
var fs = util.fs();
var contents = 'This is a file.';
let fs = util.fs();
let contents = 'This is a file.';

fs.writeFile('/myfile', contents, function (error) {
if (error) throw error;
@@ -69,8 +71,8 @@ describe('fs.access', function () {
});

it('should return no error if file does exist and mode = W_OK', function (done) {
var fs = util.fs();
var contents = 'This is a file.';
let fs = util.fs();
let contents = 'This is a file.';

fs.writeFile('/myfile', contents, function (error) {
if (error) throw error;
@@ -83,8 +85,8 @@ describe('fs.access', function () {
});

it('should return an error if file is not executable and mode = X_OK', function (done) {
var fs = util.fs();
var contents = 'This is a file.';
let fs = util.fs();
let contents = 'This is a file.';

fs.writeFile('/myfile', contents, function (error) {
if (error) throw error;
@@ -102,8 +104,8 @@ describe('fs.access', function () {
});

it('should return no error if file does exist and mode = X_OK', function (done) {
var fs = util.fs();
var contents = 'This is a file.';
let fs = util.fs();
let contents = 'This is a file.';

fs.writeFile('/myfile', contents, function (error) {
if (error) throw error;
@@ -120,8 +122,8 @@ describe('fs.access', function () {
});

it('should return no error if file does exist and no mode is passed', function (done) {
var fs = util.fs();
var contents = 'This is a file.';
let fs = util.fs();
let contents = 'This is a file.';

fs.writeFile('/myfile', contents, function (error) {
if (error) throw error;
@@ -134,8 +136,8 @@ describe('fs.access', function () {
});

it('should return no error if file does exist and mode = R_OK | W_OK', function (done) {
var fs = util.fs();
var contents = 'This is a file.';
let fs = util.fs();
let contents = 'This is a file.';

fs.writeFile('/myfile', contents, function (error) {
if (error) throw error;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.