Skip to content

Commit 7920c02

Browse files
committed
Adjust mocks to account for root expectations
1 parent e3cd949 commit 7920c02

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

tests/unit/Config.test.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -797,9 +797,10 @@ describe('Config Unit Tests', function() {
797797
}
798798
});
799799
stubLoadPkgJson.returns({root: true, rules: {}});
800-
stubLoad.returns({rules: {'require-name': 'error'}});
800+
stubLoad.returns({root: true, rules: {'require-name': 'error'}});
801801

802802
const expectedConfigObj = {
803+
root: true,
803804
rules: {
804805
'require-name': 'error'
805806
}
@@ -1031,7 +1032,8 @@ describe('Config Unit Tests', function() {
10311032
const stubLoadPkgJson = sinon.stub(ConfigFile, 'loadFromPackageJson');
10321033
const stubLoad = sinon.stub(ConfigFile, 'load');
10331034

1034-
stubDirname.returns('./npm-package-json-lint/');
1035+
stubDirname.onCall(0).returns('./npm-package-json-lint/');
1036+
stubDirname.onCall(1).returns('/home');
10351037
stubExists.returns(false);
10361038

10371039
const expectedConfigObj = {
@@ -1040,7 +1042,7 @@ describe('Config Unit Tests', function() {
10401042
const filePath = './package.json';
10411043
const result = config.getProjectHierarchyConfig(filePath);
10421044

1043-
stubDirname.calledOnce.should.be.true;
1045+
stubDirname.calledTwice.should.be.true;
10441046
stubDirname.firstCall.calledWithExactly(filePath).should.be.true;
10451047

10461048
stubExists.calledThrice.should.be.true;
@@ -1078,7 +1080,8 @@ describe('Config Unit Tests', function() {
10781080
const stubLoadPkgJson = sinon.stub(ConfigFile, 'loadFromPackageJson');
10791081
const stubLoad = sinon.stub(ConfigFile, 'load');
10801082

1081-
stubDirname.returns('./npm-package-json-lint/');
1083+
stubDirname.onCall(0).returns('./npm-package-json-lint/');
1084+
stubDirname.onCall(1).returns('/home');
10821085
stubExists.returns(true);
10831086
stubStats.returns({
10841087
isFile: function() {
@@ -1095,7 +1098,7 @@ describe('Config Unit Tests', function() {
10951098
const filePath = './package.json';
10961099
const result = config.getProjectHierarchyConfig(filePath);
10971100

1098-
stubDirname.calledOnce.should.be.true;
1101+
stubDirname.calledTwice.should.be.true;
10991102
stubDirname.firstCall.calledWithExactly(filePath).should.be.true;
11001103

11011104
stubExists.calledOnce.should.be.true;

0 commit comments

Comments
 (0)