pve-eslint/eslint/tests/lib/cli-engine/load-rules.js
Thomas Lamprecht 609c276fc2 import 8.3.0 source
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-12-01 13:39:06 +01:00

34 lines
1.0 KiB
JavaScript

/**
* @fileoverview Tests for loading rules from a directory
* @author Teddy Katz
*/
"use strict";
//-----------------------------------------------------------------------------
// Requirements
//-----------------------------------------------------------------------------
const assert = require("chai").assert;
const loadRules = require("../../../lib/cli-engine/load-rules");
//-----------------------------------------------------------------------------
// Tests
//-----------------------------------------------------------------------------
describe("when given an invalid rules directory", () => {
it("should throw an error", () => {
assert.throws(() => {
loadRules("invalidDir");
});
});
});
describe("when given a valid rules directory", () => {
it("should load rules and not throw an error", () => {
const rules = loadRules("tests/fixtures/rules", process.cwd());
assert.strictEqual(rules["fixture-rule"], require(require.resolve("../../fixtures/rules/fixture-rule")));
});
});