Skip to content

Commit

Permalink
Handling empty objects
Browse files Browse the repository at this point in the history
  • Loading branch information
alecxe committed Sep 30, 2016
1 parent 0efd731 commit 4a8a686
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/rules/max-top-level-suites.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ var R = require('ramda'),
module.exports = function (context) {
var stack = [],
topLevelDescribes = [],
suiteLimit = context.options[0];
options = context.options[0] || {},
suiteLimit;

if (R.isNil(suiteLimit)) {
if (R.isNil(options.limit)) {
suiteLimit = defaultSuiteLimit;
} else {
suiteLimit = suiteLimit.limit;
suiteLimit = options.limit;
}

return {
Expand Down
12 changes: 12 additions & 0 deletions test/rules/max-top-level-suites.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ ruleTester.run('max-top-level-suites', rules['max-top-level-suites'], {
options: [ { limit: 0 } ],
code: 'someOtherFunction();'
},
{
options: [ { } ],
code: 'someOtherFunction();'
},
'someOtherFunction();'
],

Expand Down Expand Up @@ -139,6 +143,14 @@ ruleTester.run('max-top-level-suites', rules['max-top-level-suites'], {
errors: [
{ message: 'The number of top-level suites is more than 0.' }
]
},
{
options: [ { } ],
code: 'describe("this is a test", function () { });' +
'describe.only("this is a different test", function () { });',
errors: [
{ message: 'The number of top-level suites is more than 1.' }
]
}
]
});

0 comments on commit 4a8a686

Please sign in to comment.