]> git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/shared/naming.js
first commit
[pve-eslint.git] / eslint / tests / lib / shared / naming.js
1 /**
2 * @fileoverview Tests for naming util
3 */
4 "use strict";
5
6 //------------------------------------------------------------------------------
7 // Requirements
8 //------------------------------------------------------------------------------
9
10 const assert = require("chai").assert,
11 leche = require("leche"),
12 naming = require("../../../lib/shared/naming");
13
14 //------------------------------------------------------------------------------
15 // Tests
16 //------------------------------------------------------------------------------
17
18 describe("naming", () => {
19 describe("normalizePackageName()", () => {
20
21 leche.withData([
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");
32
33 assert.strictEqual(result, expected);
34 });
35 });
36
37 });
38
39 describe("getShorthandName()", () => {
40
41 leche.withData([
42 ["foo", "foo"],
43 ["eslint-config-foo", "foo"],
44 ["@z", "@z"],
45 ["@z/eslint-config", "@z"],
46 ["@z/foo", "@z/foo"],
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");
51
52 assert.strictEqual(result, expected);
53 });
54 });
55
56 });
57
58 describe("getNamespaceFromTerm()", () => {
59 it("should remove namespace when passed with namespace", () => {
60 const namespace = naming.getNamespaceFromTerm("@namespace/eslint-plugin-test");
61
62 assert.strictEqual(namespace, "@namespace/");
63 });
64 });
65 });