-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
naming.js
64 lines (50 loc) · 2.05 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
/**
* @fileoverview Tests for naming util
*/
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
import { assert } from "chai";
import * as naming from "../../../lib/shared/naming.js";
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
describe("naming", () => {
describe("normalizePackageName()", () => {
[
["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"]
].forEach(([input, expected]) => {
it(`should return ${expected} when passed ${input}`, () => {
const result = naming.normalizePackageName(input, "eslint-config");
assert.strictEqual(result, expected);
});
});
});
describe("getShorthandName()", () => {
[
["foo", "foo"],
["eslint-config-foo", "foo"],
["@z", "@z"],
["@z/eslint-config", "@z"],
["@z/foo", "@z/foo"],
["@z/eslint-config-foo", "@z/foo"]
].forEach(([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 namespace when passed with namespace", () => {
const namespace = naming.getNamespaceFromTerm("@namespace/eslint-plugin-test");
assert.strictEqual(namespace, "@namespace/");
});
});
});