]> git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/rules/no-ternary.js
first commit
[pve-eslint.git] / eslint / tests / lib / rules / no-ternary.js
1 /**
2 * @fileoverview Tests for no-ternary.
3 * @author Ian Christian Myers
4 */
5
6 "use strict";
7
8 //------------------------------------------------------------------------------
9 // Requirements
10 //------------------------------------------------------------------------------
11
12 const rule = require("../../../lib/rules/no-ternary"),
13 { RuleTester } = require("../../../lib/rule-tester");
14
15 //------------------------------------------------------------------------------
16 // Tests
17 //------------------------------------------------------------------------------
18
19 const ruleTester = new RuleTester();
20
21 ruleTester.run("no-ternary", rule, {
22 valid: [
23 "\"x ? y\";"
24 ],
25 invalid: [
26 { code: "var foo = true ? thing : stuff;", errors: [{ messageId: "noTernaryOperator", type: "ConditionalExpression" }] },
27 { code: "true ? thing() : stuff();", errors: [{ messageId: "noTernaryOperator", type: "ConditionalExpression" }] },
28 { code: "function foo(bar) { return bar ? baz : qux; }", errors: [{ messageId: "noTernaryOperator", type: "ConditionalExpression" }] }
29 ]
30 });