| 
 | 1 | +'use strict'  | 
 | 2 | + | 
 | 3 | +var rule = require('../../lib/rules/no-angular-attributes')  | 
 | 4 | +var RuleTester = require('eslint').RuleTester  | 
 | 5 | + | 
 | 6 | +var eslintTester = new RuleTester()  | 
 | 7 | + | 
 | 8 | +eslintTester.run('no-angular-attributes', rule, {  | 
 | 9 | +  valid: [  | 
 | 10 | +    'element(by.css("input"));',  | 
 | 11 | +    'element(by.css("[ng-show"));',  | 
 | 12 | +    'element.all(by.css(".container"));',  | 
 | 13 | +    '$(".show");',  | 
 | 14 | +    '$$(".hide");',  | 
 | 15 | +    '$("[cloak]");',  | 
 | 16 | +    '$("[test-ng-cloak]");',  | 
 | 17 | +    '$$("a[href^=/], .container:has(nav)");',  | 
 | 18 | +    '$("a[href^=/], .container");',  | 
 | 19 | +    'element(by.id("id")).$$("a[href^=/]");',  | 
 | 20 | +    'element(by.id("id")).$("input");',  | 
 | 21 | +    'var s = "ng-cloak";',  | 
 | 22 | +    'element(by.id("data-ng-pattern"));',  | 
 | 23 | +    '$("");',  | 
 | 24 | +    '$();',  | 
 | 25 | +    '$$();',  | 
 | 26 | +    'element(by.css());',  | 
 | 27 | +    'element.all(by.css());'  | 
 | 28 | +  ],  | 
 | 29 | + | 
 | 30 | +  invalid: [  | 
 | 31 | +    {  | 
 | 32 | +      code: 'element(by.css("[ng-show=test]"));',  | 
 | 33 | +      errors: [  | 
 | 34 | +        {  | 
 | 35 | +          message: 'Unexpected Angular attribute "ng-show" inside a CSS selector'  | 
 | 36 | +        }  | 
 | 37 | +      ]  | 
 | 38 | +    },  | 
 | 39 | +    {  | 
 | 40 | +      code: 'element.all(by.css("[ng-hide]"));',  | 
 | 41 | +      errors: [  | 
 | 42 | +        {  | 
 | 43 | +          message: 'Unexpected Angular attribute "ng-hide" inside a CSS selector'  | 
 | 44 | +        }  | 
 | 45 | +      ]  | 
 | 46 | +    },  | 
 | 47 | +    {  | 
 | 48 | +      code: '$("[ng-src*=test]");',  | 
 | 49 | +      errors: [  | 
 | 50 | +        {  | 
 | 51 | +          message: 'Unexpected Angular attribute "ng-src" inside a CSS selector'  | 
 | 52 | +        }  | 
 | 53 | +      ]  | 
 | 54 | +    },  | 
 | 55 | +    {  | 
 | 56 | +      code: '$$("[x-ng-href$=com]");',  | 
 | 57 | +      errors: [  | 
 | 58 | +        {  | 
 | 59 | +          message: 'Unexpected Angular attribute "x-ng-href" inside a CSS selector'  | 
 | 60 | +        }  | 
 | 61 | +      ]  | 
 | 62 | +    },  | 
 | 63 | +    {  | 
 | 64 | +      code: '$("[data-ng-cloak]");',  | 
 | 65 | +      errors: [  | 
 | 66 | +        {  | 
 | 67 | +          message: 'Unexpected Angular attribute "data-ng-cloak" inside a CSS selector'  | 
 | 68 | +        }  | 
 | 69 | +      ]  | 
 | 70 | +    },  | 
 | 71 | +    {  | 
 | 72 | +      code: '$$("a[href^=/], .container:has(nav) > [ng-focus]");',  | 
 | 73 | +      errors: [  | 
 | 74 | +        {  | 
 | 75 | +          message: 'Unexpected Angular attribute "ng-focus" inside a CSS selector'  | 
 | 76 | +        }  | 
 | 77 | +      ]  | 
 | 78 | +    },  | 
 | 79 | +    {  | 
 | 80 | +      code: '$("a[href^=/], [ng-init*=\'test\'] > .container");',  | 
 | 81 | +      errors: [  | 
 | 82 | +        {  | 
 | 83 | +          message: 'Unexpected Angular attribute "ng-init" inside a CSS selector'  | 
 | 84 | +        }  | 
 | 85 | +      ]  | 
 | 86 | +    },  | 
 | 87 | +    {  | 
 | 88 | +      code: 'element(by.id("id")).$$("[ng-blur^=expression], a[href^=/]");',  | 
 | 89 | +      errors: [  | 
 | 90 | +        {  | 
 | 91 | +          message: 'Unexpected Angular attribute "ng-blur" inside a CSS selector'  | 
 | 92 | +        }  | 
 | 93 | +      ]  | 
 | 94 | +    },  | 
 | 95 | +    {  | 
 | 96 | +      code: 'element(by.id("id")).$("[data-ng-pattern*=\'test\']");',  | 
 | 97 | +      errors: [  | 
 | 98 | +        {  | 
 | 99 | +          message: 'Unexpected Angular attribute "data-ng-pattern" inside a CSS selector'  | 
 | 100 | +        }  | 
 | 101 | +      ]  | 
 | 102 | +    },  | 
 | 103 | +    {  | 
 | 104 | +      code: 'element(by.id("id")).$("[ng-show][data-ng-src]");',  | 
 | 105 | +      errors: [  | 
 | 106 | +        {  | 
 | 107 | +          message: 'Unexpected Angular attribute "ng-show" inside a CSS selector'  | 
 | 108 | +        },  | 
 | 109 | +        {  | 
 | 110 | +          message: 'Unexpected Angular attribute "data-ng-src" inside a CSS selector'  | 
 | 111 | +        }  | 
 | 112 | +      ]  | 
 | 113 | +    }  | 
 | 114 | +  ]  | 
 | 115 | +})  | 
0 commit comments