-
-
Notifications
You must be signed in to change notification settings - Fork 136
/
Copy pathlanguageUtils.test.ts
53 lines (46 loc) · 1.76 KB
/
languageUtils.test.ts
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
import { describe, it, expect } from "vitest";
import { defaultSlugifiedSubLanguageName } from "../src/utils/consts";
import {
getLanguageDisplayName,
getLanguageDisplayLogo,
getLanguageFileName,
} from "../src/utils/languageUtils";
describe(getLanguageDisplayName.name, () => {
it("should return the upper cased subLanguage if it is not the default", () => {
const result = getLanguageDisplayName("JAVASCRIPT", "React");
expect(result).toBe("REACT");
});
it("should return the language name if subLanguage is the default", () => {
const result = getLanguageDisplayName(
"JAVASCRIPT",
defaultSlugifiedSubLanguageName
);
expect(result).toBe("JAVASCRIPT");
});
});
describe(getLanguageDisplayLogo.name, () => {
it("should return a concatenation of the language and subLanguage if subLanguage is not the default", () => {
const result = getLanguageDisplayLogo("JAVASCRIPT", "React");
expect(result).toBe("/icons/javascript--react.svg");
});
it("should return the language name only if subLanguage is the default", () => {
const result = getLanguageDisplayLogo(
"JAVASCRIPT",
defaultSlugifiedSubLanguageName
);
expect(result).toBe("/icons/javascript.svg");
});
});
describe(getLanguageFileName.name, () => {
it("should return a concatenation of the language and subLanguage if subLanguage is not the default", () => {
const result = getLanguageFileName("JAVASCRIPT", "React");
expect(result).toBe("/consolidated/javascript--react.json");
});
it("should return the language name only if subLanguage is the default", () => {
const result = getLanguageFileName(
"JAVASCRIPT",
defaultSlugifiedSubLanguageName
);
expect(result).toBe("/consolidated/javascript.json");
});
});