|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +//------------------------------------------------------------------------------ |
| 4 | +// Requirements |
| 5 | +//------------------------------------------------------------------------------ |
| 6 | + |
| 7 | +const rule = require('../../../lib/rules/no-builtin-form-components'); |
| 8 | +const RuleTester = require('eslint').RuleTester; |
| 9 | + |
| 10 | +//------------------------------------------------------------------------------ |
| 11 | +// Tests |
| 12 | +//------------------------------------------------------------------------------ |
| 13 | + |
| 14 | +const { ERROR_MESSAGE } = rule; |
| 15 | +const parserOptions = { |
| 16 | + ecmaVersion: 2022, |
| 17 | + sourceType: 'module', |
| 18 | +}; |
| 19 | +const ruleTester = new RuleTester({ parserOptions }); |
| 20 | + |
| 21 | +ruleTester.run('no-builtin-form-components', rule, { |
| 22 | + valid: [ |
| 23 | + "import Component from '@ember/component';", |
| 24 | + "import { setComponentTemplate } from '@ember/component';", |
| 25 | + "import { helper } from '@ember/component/helper';", |
| 26 | + "import { Input } from 'custom-component';", |
| 27 | + "import { Textarea } from 'custom-component';", |
| 28 | + ], |
| 29 | + |
| 30 | + invalid: [ |
| 31 | + { |
| 32 | + code: "import { Input } from '@ember/component';", |
| 33 | + output: null, |
| 34 | + errors: [ |
| 35 | + { |
| 36 | + message: ERROR_MESSAGE, |
| 37 | + type: 'ImportSpecifier', |
| 38 | + }, |
| 39 | + ], |
| 40 | + }, |
| 41 | + { |
| 42 | + code: "import { Textarea } from '@ember/component';", |
| 43 | + output: null, |
| 44 | + errors: [ |
| 45 | + { |
| 46 | + message: ERROR_MESSAGE, |
| 47 | + type: 'ImportSpecifier', |
| 48 | + }, |
| 49 | + ], |
| 50 | + }, |
| 51 | + { |
| 52 | + code: "import { Input, Textarea } from '@ember/component';", |
| 53 | + output: null, |
| 54 | + errors: [ |
| 55 | + { |
| 56 | + message: ERROR_MESSAGE, |
| 57 | + type: 'ImportSpecifier', |
| 58 | + }, |
| 59 | + { |
| 60 | + message: ERROR_MESSAGE, |
| 61 | + type: 'ImportSpecifier', |
| 62 | + }, |
| 63 | + ], |
| 64 | + }, |
| 65 | + { |
| 66 | + code: "import { Input as EmberInput } from '@ember/component';", |
| 67 | + output: null, |
| 68 | + errors: [ |
| 69 | + { |
| 70 | + message: ERROR_MESSAGE, |
| 71 | + type: 'ImportSpecifier', |
| 72 | + }, |
| 73 | + ], |
| 74 | + }, |
| 75 | + { |
| 76 | + code: "import { Textarea as EmberTextarea } from '@ember/component';", |
| 77 | + output: null, |
| 78 | + errors: [ |
| 79 | + { |
| 80 | + message: ERROR_MESSAGE, |
| 81 | + type: 'ImportSpecifier', |
| 82 | + }, |
| 83 | + ], |
| 84 | + }, |
| 85 | + ], |
| 86 | +}); |
0 commit comments