]> git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/rules/no-new-symbol.js
4868592a2a21d41e501b96e6bf2d4176081852e8
[pve-eslint.git] / eslint / tests / lib / rules / no-new-symbol.js
1 /**
2 * @fileoverview Tests for the no-new-symbol rule
3 * @author Alberto Rodríguez
4 */
5
6 "use strict";
7
8 //------------------------------------------------------------------------------
9 // Requirements
10 //------------------------------------------------------------------------------
11
12 const rule = require("../../../lib/rules/no-new-symbol"),
13 { RuleTester } = require("../../../lib/rule-tester");
14
15 //------------------------------------------------------------------------------
16 // Tests
17 //------------------------------------------------------------------------------
18
19 const ruleTester = new RuleTester({ env: { es6: true } });
20
21 ruleTester.run("no-new-symbol", rule, {
22 valid: [
23 "var foo = Symbol('foo');",
24 "function bar(Symbol) { var baz = new Symbol('baz');}",
25 "function Symbol() {} new Symbol();"
26 ],
27 invalid: [
28 {
29 code: "var foo = new Symbol('foo');",
30 errors: [{ messageId: "noNewSymbol" }]
31 },
32 {
33 code: "function bar() { return function Symbol() {}; } var baz = new Symbol('baz');",
34 errors: [{ messageId: "noNewSymbol" }]
35 }
36 ]
37 });