|
| 1 | +//------------------------------------------------------------------------------ |
| 2 | +// Requirements |
| 3 | +//------------------------------------------------------------------------------ |
| 4 | + |
| 5 | +var rule = require('../rules/ng_di_unused'), |
| 6 | + RuleTester = require("eslint").RuleTester; |
| 7 | + |
| 8 | +//------------------------------------------------------------------------------ |
| 9 | +// Tests |
| 10 | +//------------------------------------------------------------------------------ |
| 11 | + |
| 12 | +var eslintTester = new RuleTester(); |
| 13 | +eslintTester.run('ng_di_unused', rule, { |
| 14 | + valid: [ |
| 15 | + 'app.controller("", function($q){return $q;});', |
| 16 | + 'app.directive("", function($q){return $q;});', |
| 17 | + 'app.factory("", function($q){return $q;});', |
| 18 | + 'app.factory("", function($q){return function(){return $q;};});', |
| 19 | + 'app.factory("", function(){var myVar;});', |
| 20 | + 'app.filter("", function($q){return $q;});', |
| 21 | + 'app.provider("", function($httpProvider){return $httpProvider;});', |
| 22 | + 'app.service("", function($q){return $q;});', |
| 23 | + 'app.config(function($httpProvider) {$httpProvider.defaults.headers.post.answer="42"})', |
| 24 | + 'app.run(function($q) {$q()})', |
| 25 | + 'inject(function($q){_$q_ = $q;});', |
| 26 | + 'this.$get = function($q){return $q;};', |
| 27 | + ], |
| 28 | + invalid: [{ |
| 29 | + code: 'app.controller("", function($q){});', |
| 30 | + errors: [{message: 'Unused injected value $q'}] |
| 31 | + }, { |
| 32 | + code: 'app.directive("", function($q){});', |
| 33 | + errors: [{message: 'Unused injected value $q'}] |
| 34 | + }, { |
| 35 | + code: 'app.factory("", function($q){});', |
| 36 | + errors: [{message: 'Unused injected value $q'}] |
| 37 | + }, { |
| 38 | + code: 'app.factory("", function($http, $q){});', |
| 39 | + errors: [ |
| 40 | + {message: 'Unused injected value $http'}, |
| 41 | + {message: 'Unused injected value $q'} |
| 42 | + ] |
| 43 | + }, { |
| 44 | + code: 'app.factory("", function($http, $q){return $q.resolve()});', |
| 45 | + errors: [ |
| 46 | + {message: 'Unused injected value $http'} |
| 47 | + ] |
| 48 | + }, { |
| 49 | + code: 'app.filter("", function($q){});', |
| 50 | + errors: [{message: 'Unused injected value $q'}] |
| 51 | + }, { |
| 52 | + code: 'app.provider("", function($httpProvider){});', |
| 53 | + errors: [{message: 'Unused injected value $httpProvider'}] |
| 54 | + }, { |
| 55 | + code: 'app.service("", function($q){});', |
| 56 | + errors: [{message: 'Unused injected value $q'}] |
| 57 | + }, { |
| 58 | + code: 'app.config(function($httpProvider) {})', |
| 59 | + errors: [{message: 'Unused injected value $httpProvider'}] |
| 60 | + }, { |
| 61 | + code: 'app.run(function($q){});', |
| 62 | + errors: [{message: 'Unused injected value $q'}] |
| 63 | + }, { |
| 64 | + code: 'inject(function($q){});', |
| 65 | + errors: [{message: 'Unused injected value $q'}] |
| 66 | + }, { |
| 67 | + code: 'this.$get = function($q){};', |
| 68 | + errors: [{message: 'Unused injected value $q'}] |
| 69 | + }] |
| 70 | +}); |
0 commit comments