11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci/* eslint-disable no-template-curly-in-string */
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst common = require('../common');
61cb0ef41Sopenharmony_ciif ((!common.hasCrypto) || (!common.hasIntl)) {
71cb0ef41Sopenharmony_ci  common.skip('ESLint tests require crypto and Intl');
81cb0ef41Sopenharmony_ci}
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_cicommon.skipIfEslintMissing();
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ciconst RuleTester = require('../../tools/node_modules/eslint').RuleTester;
131cb0ef41Sopenharmony_ciconst rule = require('../../tools/eslint-rules/prefer-util-format-errors');
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_cinew RuleTester({ parserOptions: { ecmaVersion: 6 } })
161cb0ef41Sopenharmony_ci  .run('prefer-util-format-errors', rule, {
171cb0ef41Sopenharmony_ci    valid: [
181cb0ef41Sopenharmony_ci      'E(\'ABC\', \'abc\');',
191cb0ef41Sopenharmony_ci      'E(\'ABC\', (arg1, arg2) => `${arg2}${arg1}`);',
201cb0ef41Sopenharmony_ci      'E(\'ABC\', (arg1, arg2) => `${arg1}{arg2.something}`);',
211cb0ef41Sopenharmony_ci      'E(\'ABC\', (arg1, arg2) => fn(arg1, arg2));',
221cb0ef41Sopenharmony_ci    ],
231cb0ef41Sopenharmony_ci    invalid: [
241cb0ef41Sopenharmony_ci      {
251cb0ef41Sopenharmony_ci        code: 'E(\'ABC\', (arg1, arg2) => `${arg1}${arg2}`);',
261cb0ef41Sopenharmony_ci        errors: [{
271cb0ef41Sopenharmony_ci          message: 'Please use a printf-like formatted string that ' +
281cb0ef41Sopenharmony_ci                   'util.format can consume.'
291cb0ef41Sopenharmony_ci        }]
301cb0ef41Sopenharmony_ci      },
311cb0ef41Sopenharmony_ci    ]
321cb0ef41Sopenharmony_ci  });
33