Skip to content

Commit

Permalink
updated tests to eslint 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamund Ferguson committed Jun 3, 2016
1 parent 782b7f2 commit bb1ed7e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"test": "mocha test"
},
"devDependencies": {
"eslint": "~1.2.0",
"eslint": "^2.11.1",
"mocha": "^2.3.4",
"standard": "^5.4.1"
},
Expand Down
28 changes: 14 additions & 14 deletions test/always-return.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
var rule = require('../rules/always-return')
var RuleTester = require('eslint').RuleTester
var message = 'Each then() should return a value or throw'
var ecmaFeatures = { arrowFunctions: true }
var parserOptions = { ecmaVersion: 6 }
var ruleTester = new RuleTester()
ruleTester.run('always-return', rule, {
valid: [
{ code: 'hey.then(x => x)', ecmaFeatures: ecmaFeatures },
{ code: 'hey.then(x => ({}))', ecmaFeatures: ecmaFeatures },
{ code: 'hey.then(x => { return x * 10 })', ecmaFeatures: ecmaFeatures },
{ code: 'hey.then(function() { return 42; })', ecmaFeatures: ecmaFeatures },
{ code: 'hey.then(function() { return new Promise(); })', ecmaFeatures: ecmaFeatures },
{ code: 'hey.then(x => x)', parserOptions: parserOptions },
{ code: 'hey.then(x => ({}))', parserOptions: parserOptions },
{ code: 'hey.then(x => { return x * 10 })', parserOptions: parserOptions },
{ code: 'hey.then(function() { return 42; })', parserOptions: parserOptions },
{ code: 'hey.then(function() { return new Promise(); })', parserOptions: parserOptions },
{ code: 'hey.then(function() { return "x"; }).then(doSomethingWicked)' },
{ code: 'hey.then(x => x).then(function() { return "3" })', ecmaFeatures: ecmaFeatures },
{ code: 'hey.then(function() { throw new Error("msg"); })', ecmaFeatures: ecmaFeatures },
{ code: 'hey.then(function(x) { if (!x) { throw new Error("no x"); } return x; })', ecmaFeatures: ecmaFeatures },
{ code: 'hey.then(function(x) { if (x) { return x; } throw new Error("no x"); })', ecmaFeatures: ecmaFeatures },
{ code: 'hey.then(x => { throw new Error("msg"); })', ecmaFeatures: ecmaFeatures },
{ code: 'hey.then(x => { if (!x) { throw new Error("no x"); } return x; })', ecmaFeatures: ecmaFeatures },
{ code: 'hey.then(x => { if (x) { return x; } throw new Error("no x"); })', ecmaFeatures: ecmaFeatures }
{ code: 'hey.then(x => x).then(function() { return "3" })', parserOptions: parserOptions },
{ code: 'hey.then(function() { throw new Error("msg"); })', parserOptions: parserOptions },
{ code: 'hey.then(function(x) { if (!x) { throw new Error("no x"); } return x; })', parserOptions: parserOptions },
{ code: 'hey.then(function(x) { if (x) { return x; } throw new Error("no x"); })', parserOptions: parserOptions },
{ code: 'hey.then(x => { throw new Error("msg"); })', parserOptions: parserOptions },
{ code: 'hey.then(x => { if (!x) { throw new Error("no x"); } return x; })', parserOptions: parserOptions },
{ code: 'hey.then(x => { if (x) { return x; } throw new Error("no x"); })', parserOptions: parserOptions }
],

invalid: [
{
code: 'hey.then(x => {})',
ecmaFeatures: ecmaFeatures,
parserOptions: parserOptions,
errors: [ { message: message } ]
},
{
Expand Down
28 changes: 26 additions & 2 deletions test/no-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

var rule = require('../rules/no-native')
var RuleTester = require('eslint').RuleTester

var parserOptions = { sourceType: 'module', ecmaVersion: 6 }
var ruleTester = new RuleTester()
ruleTester.run('no-native', rule, {
valid: [
'var Promise = null; function x() { return Promise.resolve("hi"); }',
'var Promise = window.Promise || require("bluebird"); var x = Promise.reject();'
'var Promise = window.Promise || require("bluebird"); var x = Promise.reject();',
{ code: 'var Promise = null; function x() { return Promise.resolve("hi"); }', parserOptions: parserOptions },
{ code: 'var Promise = window.Promise || require("bluebird"); var x = Promise.reject();', parserOptions: parserOptions },
{ code: 'import Promise from "bluebird"; var x = Promise.reject();', parserOptions: parserOptions }
],

invalid: [
Expand All @@ -18,6 +21,27 @@ ruleTester.run('no-native', rule, {
{
code: 'Promise.resolve()',
errors: [ { message: '"Promise" is not defined.' } ]
},
{
code: 'new Promise(function(reject, resolve) { })',
errors: [ { message: '"Promise" is not defined.' } ],
env: { browser: true }
},
{
code: 'new Promise(function(reject, resolve) { })',
errors: [ { message: '"Promise" is not defined.' } ],
env: { node: true }
},
{
code: 'Promise.resolve()',
errors: [ { message: '"Promise" is not defined.' } ],
env: { es6: true }
},
{
code: 'Promise.resolve()',
errors: [ { message: '"Promise" is not defined.' } ],
globals: { Promise: true }
}

]
})

0 comments on commit bb1ed7e

Please sign in to comment.