-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetFileTypeFromPathTest.ts
48 lines (47 loc) · 1.68 KB
/
getFileTypeFromPathTest.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
import { expect } from "chai";
import { getFileTypeFromPath } from "./getFileTypeFromPath";
import "mocha";
describe("Finds file type of path depending on the amount of dots, placement of dots, and placement of forward slashes", () => {
// FileType.FILE test
it("should return FILE", () => {
const result = getFileTypeFromPath("src/tree/index.ts", true);
expect(result).to.equal("FILE");
});
// FileType.FILE test
it("should return FILE", () => {
const result = getFileTypeFromPath("src/tree/2020.index.ts", true);
expect(result).to.equal("FILE");
});
// FileType.CONFIG_FILE test
it("should return CONFIG_FILE", () => {
const result = getFileTypeFromPath("src/.eslintrc.js", true);
expect(result).to.equal("CONFIG_FILE");
});
// FileType.FOLDER test
it("should return FOLDER", () => {
const result = getFileTypeFromPath("src/tree", false);
expect(result).to.equal("FOLDER");
});
it("should return FOLDER", () => {
const result = getFileTypeFromPath("src/.tree", false);
expect(result).to.equal("FOLDER");
});
// Edge case test
it('should return "Path/file is invalid!"', () => {
expect(() =>
getFileTypeFromPath("./src/tree/../w.e.e/we.we///", true)
).to.throw();
});
// Edge case test
it('should return "Path/file is invalid!"', () => {
expect(() => getFileTypeFromPath("./src/tree/", false)).to.throw();
});
// Edge case test
it('should return "Path/file is invalid!"', () => {
expect(() => getFileTypeFromPath("src/tree./", false)).to.throw();
});
// Edge case test
it('should return "Path/file is invalid!"', () => {
expect(() => getFileTypeFromPath("src/..tree./", false)).to.throw();
});
});