]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/shared/naming.js
2 * @fileoverview Tests for naming util
6 //------------------------------------------------------------------------------
8 //------------------------------------------------------------------------------
10 const assert
= require("chai").assert
,
11 leche
= require("leche"),
12 naming
= require("../../../lib/shared/naming");
14 //------------------------------------------------------------------------------
16 //------------------------------------------------------------------------------
18 describe("naming", () => {
19 describe("normalizePackageName()", () => {
22 ["foo", "eslint-config-foo"],
23 ["eslint-config-foo", "eslint-config-foo"],
24 ["@z/foo", "@z/eslint-config-foo"],
25 ["@z\\foo", "@z/eslint-config-foo"],
26 ["@z\\foo\\bar.js", "@z/eslint-config-foo/bar.js"],
27 ["@z/eslint-config", "@z/eslint-config"],
28 ["@z/eslint-config-foo", "@z/eslint-config-foo"]
29 ], (input
, expected
) => {
30 it(`should return ${expected} when passed ${input}`, () => {
31 const result
= naming
.normalizePackageName(input
, "eslint-config");
33 assert
.strictEqual(result
, expected
);
39 describe("getShorthandName()", () => {
43 ["eslint-config-foo", "foo"],
45 ["@z/eslint-config", "@z"],
47 ["@z/eslint-config-foo", "@z/foo"]
48 ], (input
, expected
) => {
49 it(`should return ${expected} when passed ${input}`, () => {
50 const result
= naming
.getShorthandName(input
, "eslint-config");
52 assert
.strictEqual(result
, expected
);
58 describe("getNamespaceFromTerm()", () => {
59 it("should remove namespace when passed with namespace", () => {
60 const namespace = naming
.getNamespaceFromTerm("@namespace/eslint-plugin-test");
62 assert
.strictEqual(namespace, "@namespace/");