1'use strict';
2
3const common = require('../common');
4if ((!common.hasCrypto) || (!common.hasIntl)) {
5  common.skip('ESLint tests require crypto and Intl');
6}
7
8common.skipIfEslintMissing();
9
10const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
11const rule = require('../../tools/eslint-rules/lowercase-name-for-primitive');
12
13new RuleTester().run('lowercase-name-for-primitive', rule, {
14  valid: [
15    'new errors.TypeError("ERR_INVALID_ARG_TYPE", "a", ["string", "number"])',
16    'new errors.TypeError("ERR_INVALID_ARG_TYPE", "name", "string")',
17    'new errors.TypeError("ERR_INVALID_ARG_TYPE", "name", "number")',
18    'new errors.TypeError("ERR_INVALID_ARG_TYPE", "name", "boolean")',
19    'new errors.TypeError("ERR_INVALID_ARG_TYPE", "name", "null")',
20    'new errors.TypeError("ERR_INVALID_ARG_TYPE", "name", "undefined")',
21  ],
22  invalid: [
23    {
24      code: "new errors.TypeError('ERR_INVALID_ARG_TYPE', 'a', 'Number')",
25      errors: [{ message: 'primitive should use lowercase: Number' }],
26      output: "new errors.TypeError('ERR_INVALID_ARG_TYPE', 'a', 'number')",
27    },
28    {
29      code: "new errors.TypeError('ERR_INVALID_ARG_TYPE', 'a', 'STRING')",
30      errors: [{ message: 'primitive should use lowercase: STRING' }],
31      output: "new errors.TypeError('ERR_INVALID_ARG_TYPE', 'a', 'string')",
32    },
33    {
34      code: "new e.TypeError('ERR_INVALID_ARG_TYPE', a, ['String','Number'])",
35      errors: [
36        { message: 'primitive should use lowercase: String' },
37        { message: 'primitive should use lowercase: Number' },
38      ],
39      output: "new e.TypeError('ERR_INVALID_ARG_TYPE', a, ['string','number'])",
40    },
41  ]
42});
43