/
no-div-regex.js
33 lines (27 loc) · 1.01 KB
/
no-div-regex.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
/**
* @fileoverview Tests for no-div-regex rule.
* @author Matt DuVall <http://www.mattduvall.com>
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const rule = require("../../../lib/rules/no-div-regex"),
{ RuleTester } = require("../../../lib/rule-tester");
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
const ruleTester = new RuleTester();
ruleTester.run("no-div-regex", rule, {
valid: [
"var f = function() { return /foo/ig.test('bar'); };",
"var f = function() { return /\\=foo/; };"
],
invalid: [
{
code: "var f = function() { return /=foo/; };",
output: "var f = function() { return /[=]foo/; };",
errors: [{ messageId: "unexpected", type: "Literal" }]
}
]
});