Skip to content
This repository was archived by the owner on Nov 2, 2018. It is now read-only.

Commit dbd1982

Browse files
committed
Changed all const declarations to let.
Added tests
1 parent bcd074a commit dbd1982

File tree

5 files changed

+42
-20
lines changed

5 files changed

+42
-20
lines changed

src/path.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

3-
const fs = require('fs');
4-
const path = require('path');
3+
let fs = require('fs');
4+
let path = require('path');
55

66
/**
77
* Checks if `file` exists and returns `true`, `false` otherwise.

src/project.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

3-
const path = require('path');
4-
const log = require('npmlog');
3+
let path = require('path');
4+
let log = require('npmlog');
55

66
/**
77
* Retrieve the `package.json` file from the path provided by `folder`.

tests/path.spec.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
'use strict';
22

3-
const chai = require('chai');
4-
const path = require('path');
3+
let chai = require('chai');
4+
let rewire = require('rewire');
5+
let sinon = require('sinon');
6+
let path = require('path');
57

6-
const expect = chai.expect;
8+
let expect = chai.expect;
79

8-
const pathUtils = require('../src/path');
10+
let pathUtils = require('../src/path');
911

1012
describe('path', () => {
1113

@@ -39,9 +41,29 @@ describe('path', () => {
3941

4042
describe('#makeDirectory', () => {
4143

42-
it('should create a directory if none exists');
44+
it('should create a directory if none exists', () => {
45+
let pathUtilsMock = rewire('../src/path');
46+
let stub = sinon.stub().returns(false);
47+
pathUtilsMock.__set__('fs', {
48+
existsSync: stub,
49+
mkdirSync: stub,
50+
});
4351

44-
it('should not create a directory if one exists');
52+
pathUtilsMock.makeDirectory(process.cwd());
53+
expect(stub.calledTwice).to.deep.equals(true);
54+
});
55+
56+
it('should not create a directory if one exists', () => {
57+
let pathUtilsMock = rewire('../src/path');
58+
let stub = sinon.stub().returns(true);
59+
pathUtilsMock.__set__('fs', {
60+
existsSync: stub,
61+
mkdirSync: stub,
62+
});
63+
64+
pathUtilsMock.makeDirectory(process.cwd());
65+
expect(stub.calledOnce).to.deep.equals(true);
66+
});
4567

4668
});
4769

tests/project.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
'use strict';
22

3-
const chai = require('chai');
4-
const sinon = require('sinon');
5-
const log = require('npmlog');
6-
const path = require('path');
3+
let chai = require('chai');
4+
let sinon = require('sinon');
5+
let log = require('npmlog');
6+
let path = require('path');
77

8-
const expect = chai.expect;
8+
let expect = chai.expect;
99
log.level = 'silent';
1010

11-
const projectUtils = require('../src/project');
11+
let projectUtils = require('../src/project');
1212

1313
describe('project', () => {
1414

tests/validate.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use strict';
22

3-
const chai = require('chai');
4-
const path = require('path');
3+
let chai = require('chai');
4+
let path = require('path');
55

6-
const expect = chai.expect;
6+
let expect = chai.expect;
77

8-
const validateUtils = require('../src/validate');
8+
let validateUtils = require('../src/validate');
99

1010
describe('validate', () => {
1111

0 commit comments

Comments
 (0)