-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetLargestFileNameLengthInLevelTest.ts
97 lines (95 loc) · 2.62 KB
/
getLargestFileNameLengthInLevelTest.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { expect } from 'chai';
import { getLargestFileNameLengthInLevel } from './getLargestFileNameLengthInLevel';
import 'mocha';
const treeCore = [
{
path: '',
deletedOrder: -1,
comment: '',
treeCore: [
{
path: 'src',
deletedOrder: -1,
comment: '',
treeCore: [
{
path: 'src/components',
deletedOrder: -1,
comment: '',
treeCore: [],
},
{
path: 'src/images',
deletedOrder: -1,
comment: '',
treeCore: [
{
path: 'src/images/Demo.gif',
deletedOrder: -1,
comment: '',
treeCore: [],
},
],
},
{
path: 'src/tree',
deletedOrder: -1,
comment: '',
treeCore: [],
},
{
path: 'src/utils',
deletedOrder: -1,
comment: '',
treeCore: [],
},
],
},
{
path: 'public',
deletedOrder: -1,
comment: '',
treeCore: [
{
path: 'public/favicon.ico',
deletedOrder: -1,
comment: '',
treeCore: [],
},
{
path: 'public/index.html',
deletedOrder: -1,
comment: '',
treeCore: [],
},
],
},
],
},
];
describe('Finds the largest path length in a treeCore given the depth level wanted for analysis', () => {
// Test for depthLevel 2
it('should return 11 for "public/favicon.ico"', () => {
expect(getLargestFileNameLengthInLevel(treeCore, 2)).to.equal(11);
});
// Test for depthLevel 3
it('should return 8 for "src/images/Demo.gif"', () => {
expect(getLargestFileNameLengthInLevel(treeCore, 3)).to.equal(8);
});
// Test for depthLevel 1
it('should return 6 for "public"', () => {
expect(getLargestFileNameLengthInLevel(treeCore, 1)).to.equal(6);
});
// Edge case for outOfBounds depthLevel 4
it('should return -1 since maxDepthLevel is 3 and depthLevel is 4', () => {
expect(getLargestFileNameLengthInLevel(treeCore, 4)).to.equal(-1);
});
// Edge case for outOfBounds depthLevel 5
it('should return -1 since maxDepthLevel is 3 and depthLevel is 5', () => {
expect(getLargestFileNameLengthInLevel(treeCore, 5)).to.equal(-1);
});
// Edge case for outOfBounds depthLevel 6
it('should return -1 since maxDepthLevel is 3 and depthLevel is 6', () => {
expect(getLargestFileNameLengthInLevel(treeCore, 6)).to.equal(-1);
});
});