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