1'use strict';
2
3const common = require('../common');
4if ((!common.hasCrypto) || (!common.hasIntl)) {
5  common.skip('ESLint tests require crypto and Intl');
6}
7common.skipIfEslintMissing();
8
9const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
10const rule = require('../../tools/eslint-rules/documented-errors');
11
12const invalidCode = 'UNDOCUMENTED ERROR CODE';
13
14new RuleTester().run('documented-errors', rule, {
15  valid: [
16    `
17      E('ERR_ASSERTION', 'foo');
18    `,
19  ],
20  invalid: [
21    {
22      code: `
23        E('${invalidCode}', 'bar');
24      `,
25      errors: [
26        {
27          message: `"${invalidCode}" is not documented in doc/api/errors.md`,
28          line: 2
29        },
30        {
31          message:
32            `doc/api/errors.md does not have an anchor for "${invalidCode}"`,
33          line: 2
34        },
35      ]
36    },
37  ]
38});
39