Skip to content

Commit

Permalink
Merge pull request #521 from unexpectedjs/feature/eslint-plugin-mocha
Browse files Browse the repository at this point in the history
Add and configure eslint-plugin-mocha
  • Loading branch information
papandreou committed Sep 29, 2018
2 parents 5d250a8 + f08e726 commit a319eaf
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 49 deletions.
7 changes: 5 additions & 2 deletions .eslintrc.js
@@ -1,6 +1,6 @@
const config = {
extends: ['pretty-standard'],
plugins: ['import'],
plugins: ['import', 'mocha'],
rules: {
'import/no-extraneous-dependencies': [
'error',
Expand All @@ -12,7 +12,10 @@ const config = {
optionalDependencies: false,
peerDependencies: false
}
]
],
'mocha/no-exclusive-tests': 'error',
'mocha/no-nested-tests': 'error',
'mocha/no-identical-title': 'error'
}
};

Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -41,6 +41,7 @@
"eslint": "^4.17.0",
"eslint-config-pretty-standard": "^1.2.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-mocha": "^5.2.0",
"eslint-plugin-prettier": "^2.6.0",
"find-node-modules": "^1.0.4",
"gh-pages": "^1.1.0",
Expand Down
17 changes: 0 additions & 17 deletions test/api/child.spec.js
Expand Up @@ -125,23 +125,6 @@ describe('#child', function() {
childExpect('yaddafoobar', 'to foobar');
});

it('should prefer a style defined in the child, even if it was added before an identically named one in the parent', function() {
childExpect.addStyle('yadda', function() {
this.text('yaddagood');
});
parentExpect.addStyle('yadda', function() {
this.text('yaddabad');
});
expect(
childExpect
.createOutput('text')
.yadda()
.toString(),
'to equal',
'yaddagood'
);
});

it('should allow installing an identically named plugin', function() {
parentExpect.use({
name: 'foo',
Expand Down
26 changes: 14 additions & 12 deletions test/assertions/to-satisfy.spec.js
Expand Up @@ -77,18 +77,20 @@ describe('to satisfy assertion', function() {
);
});

it('should fail', function() {
expect(
function() {
expect({ foo: {} }, 'to satisfy', { foo: [] });
},
'to throw',
'expected { foo: {} } to satisfy { foo: [] }\n' +
'\n' +
'{\n' +
' foo: {} // should satisfy []\n' +
'}'
);
describe('when the array is nested inside an object', function() {
it('should fail', function() {
expect(
function() {
expect({ foo: {} }, 'to satisfy', { foo: [] });
},
'to throw',
'expected { foo: {} } to satisfy { foo: [] }\n' +
'\n' +
'{\n' +
' foo: {} // should satisfy []\n' +
'}'
);
});
});
});

Expand Down
15 changes: 0 additions & 15 deletions test/assertions/when-fulfilled.spec.js
Expand Up @@ -59,21 +59,6 @@ describe('when fulfilled adverbial assertion', function() {
);
});

it('should fail when the promise is rejected with a value of undefined', function() {
return expect(
expect(
new Promise(function(resolve, reject) {
setTimeout(reject, 0);
}),
'when fulfilled',
'to be truthy'
),
'to be rejected with',
'expected Promise when fulfilled to be truthy\n' +
' Promise unexpectedly rejected'
);
});

it('should fail when the next assertion fails', function() {
return expect(
expect(
Expand Down
6 changes: 3 additions & 3 deletions test/types/function-type.spec.js
Expand Up @@ -228,7 +228,7 @@ describe('function type', function() {
} catch (e) {}

if (arrowFunctionWith1SpaceIndentAndLeadingNewline) {
it('should reindent an implicit return multiline arrow function', function() {
it('should reindent an implicit return multiline arrow function with 1 space indent', function() {
expect(
arrowFunctionWith1SpaceIndentAndLeadingNewline,
'to inspect as',
Expand All @@ -247,7 +247,7 @@ describe('function type', function() {
} catch (e) {}

if (arrowFunctionWith2SpaceIndentAndLeadingNewline) {
it('should reindent an implicit return multiline arrow function', function() {
it('should reindent an implicit return multiline arrow function with 2 space indent', function() {
expect(
arrowFunctionWith2SpaceIndentAndLeadingNewline,
'to inspect as',
Expand Down Expand Up @@ -285,7 +285,7 @@ describe('function type', function() {
} catch (e) {}

if (arrowFunctionWith4SpaceIndentAndLeadingNewline) {
it('should reindent an implicit return multiline arrow function with 4 space indent', function() {
it('should reindent an implicit return multiline arrow function with long leading indent', function() {
expect(
arrowFunctionWith4SpaceIndentAndLeadingNewline,
'to inspect as',
Expand Down

0 comments on commit a319eaf

Please sign in to comment.