/
naming.js
65 lines (52 loc) · 2.1 KB
/
naming.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* @fileoverview Tests for naming util
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const assert = require("chai").assert,
leche = require("leche"),
naming = require("../../../lib/shared/naming");
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
describe("naming", () => {
describe("normalizePackageName()", () => {
leche.withData([
["foo", "eslint-config-foo"],
["eslint-config-foo", "eslint-config-foo"],
["@z/foo", "@z/eslint-config-foo"],
["@z\\foo", "@z/eslint-config-foo"],
["@z\\foo\\bar.js", "@z/eslint-config-foo/bar.js"],
["@z/eslint-config", "@z/eslint-config"],
["@z/eslint-config-foo", "@z/eslint-config-foo"]
], (input, expected) => {
it(`should return ${expected} when passed ${input}`, () => {
const result = naming.normalizePackageName(input, "eslint-config");
assert.strictEqual(result, expected);
});
});
});
describe("getShorthandName()", () => {
leche.withData([
["foo", "foo"],
["eslint-config-foo", "foo"],
["@z", "@z"],
["@z/eslint-config", "@z"],
["@z/foo", "@z/foo"],
["@z/eslint-config-foo", "@z/foo"]
], (input, expected) => {
it(`should return ${expected} when passed ${input}`, () => {
const result = naming.getShorthandName(input, "eslint-config");
assert.strictEqual(result, expected);
});
});
});
describe("getNamespaceFromTerm()", () => {
it("should remove namepace when passed with namepace", () => {
const namespace = naming.getNamespaceFromTerm("@namepace/eslint-plugin-test");
assert.strictEqual(namespace, "@namepace/");
});
});
});