Skip to content

Commit 4d05b77

Browse files
committed
adding tests for languageUtils
1 parent c037d18 commit 4d05b77

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

tests/languageUtils.test.ts

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { describe, it, expect } from "vitest";
2+
3+
import { defaultSlugifiedSubLanguageName } from "../src/utils/consts";
4+
import {
5+
getLanguageDisplayName,
6+
getLanguageDisplayLogo,
7+
getLanguageFileName,
8+
} from "../src/utils/languageUtils";
9+
10+
describe(getLanguageDisplayName.name, () => {
11+
it("should return the upper cased subLanguage if it is not the default", () => {
12+
const result = getLanguageDisplayName("JAVASCRIPT", "React");
13+
expect(result).toBe("REACT");
14+
});
15+
16+
it("should return the language name if subLanguage is the default", () => {
17+
const result = getLanguageDisplayName(
18+
"JAVASCRIPT",
19+
defaultSlugifiedSubLanguageName
20+
);
21+
expect(result).toBe("JAVASCRIPT");
22+
});
23+
});
24+
25+
describe(getLanguageDisplayLogo.name, () => {
26+
it("should return a concatenation of the language and subLanguage if subLanguage is not the default", () => {
27+
const result = getLanguageDisplayLogo("JAVASCRIPT", "React");
28+
expect(result).toBe("/icons/javascript--react.svg");
29+
});
30+
31+
it("should return the language name only if subLanguage is the default", () => {
32+
const result = getLanguageDisplayLogo(
33+
"JAVASCRIPT",
34+
defaultSlugifiedSubLanguageName
35+
);
36+
expect(result).toBe("/icons/javascript.svg");
37+
});
38+
});
39+
40+
describe(getLanguageFileName.name, () => {
41+
it("should return a concatenation of the language and subLanguage if subLanguage is not the default", () => {
42+
const result = getLanguageFileName("JAVASCRIPT", "React");
43+
expect(result).toBe("javascript--react.json");
44+
});
45+
46+
it("should return the language name only if subLanguage is the default", () => {
47+
const result = getLanguageFileName(
48+
"JAVASCRIPT",
49+
defaultSlugifiedSubLanguageName
50+
);
51+
expect(result).toBe("javascript.json");
52+
});
53+
});

0 commit comments

Comments
 (0)