pve-eslint/eslint/tests/lib/rules/no-div-regex.js
Dominik Csapak eb39fafa4f first commit
includes a (minimal) working wrapper

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-04-06 15:06:03 +02:00

34 lines
1.0 KiB
JavaScript

/**
* @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" }]
}
]
});