11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciif (!common.hasCrypto)
51cb0ef41Sopenharmony_ci  common.skip('missing crypto');
61cb0ef41Sopenharmony_ciif (!common.hasIntl)
71cb0ef41Sopenharmony_ci  common.skip('missing Intl');
81cb0ef41Sopenharmony_cicommon.skipIfEslintMissing();
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciconst RuleTester = require('../../tools/node_modules/eslint').RuleTester;
111cb0ef41Sopenharmony_ciconst rule = require('../../tools/eslint-rules/documented-deprecation-codes');
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciconst mdFile = 'doc/api/deprecations.md';
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ciconst invalidCode = 'UNDOCUMENTED INVALID CODE';
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_cinew RuleTester().run('documented-deprecation-codes', rule, {
181cb0ef41Sopenharmony_ci  valid: [
191cb0ef41Sopenharmony_ci    `
201cb0ef41Sopenharmony_ci    deprecate(function() {
211cb0ef41Sopenharmony_ci        return this.getHeaders();
221cb0ef41Sopenharmony_ci      }, 'OutgoingMessage.prototype._headers is deprecated', 'DEP0066')
231cb0ef41Sopenharmony_ci    `,
241cb0ef41Sopenharmony_ci  ],
251cb0ef41Sopenharmony_ci  invalid: [
261cb0ef41Sopenharmony_ci    {
271cb0ef41Sopenharmony_ci      code: `
281cb0ef41Sopenharmony_ci        deprecate(function foo(){}, 'bar', '${invalidCode}');
291cb0ef41Sopenharmony_ci      `,
301cb0ef41Sopenharmony_ci      errors: [
311cb0ef41Sopenharmony_ci        {
321cb0ef41Sopenharmony_ci          message: `"${invalidCode}" does not match the expected pattern`,
331cb0ef41Sopenharmony_ci          line: 2
341cb0ef41Sopenharmony_ci        },
351cb0ef41Sopenharmony_ci        {
361cb0ef41Sopenharmony_ci          message: `"${invalidCode}" is not documented in ${mdFile}`,
371cb0ef41Sopenharmony_ci          line: 2
381cb0ef41Sopenharmony_ci        },
391cb0ef41Sopenharmony_ci      ]
401cb0ef41Sopenharmony_ci    },
411cb0ef41Sopenharmony_ci  ]
421cb0ef41Sopenharmony_ci});
43