-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetCommentForPathtest.ts
68 lines (65 loc) · 1.73 KB
/
setCommentForPathtest.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
import { expect } from 'chai';
import setCommentForPath from './setCommentForPath';
const treeCore = [
{
path: 'src/utils',
deletedOrder: -1,
comment: ' ',
treeCore: [],
},
{
path: 'src',
deletedOrder: -1,
treeCore: [
{
path: 'src/utils', deletedOrder: -1, comment: ' ', treeCore: []
},
{
path: 'src/components',
deletedOrder: -1,
comment: ' # ss',
treeCore: [],
},
],
comment: ' # Source files',
},
{
path: 'src/components',
deletedOrder: -1,
comment: ' # ss',
treeCore: [],
},
];
describe('setCommentForPath Function', () => {
it('folder in root', () => {
const newTreeCore = setCommentForPath(treeCore, 'src', 'NEW COMMENT!');
expect(newTreeCore[1].comment).to.equal(' # NEW COMMENT!');
});
it('folder at deeper levels', () => {
const newTreeCore = setCommentForPath(
treeCore,
'src/components',
'NEW COMMENT!',
);
expect(newTreeCore[2].comment).to.equal(' # NEW COMMENT!');
expect(newTreeCore[1].treeCore[1].comment).to.equal(' # NEW COMMENT!');
});
it('folder with no comment', () => {
const newTreeCore = setCommentForPath(
treeCore,
'src/utils',
'NEW COMMENT!',
);
expect(newTreeCore[0].comment).to.equal(' # NEW COMMENT!');
});
it('deleting comment', () => {
const newTreeCore = setCommentForPath(treeCore, 'src/utils', '');
expect(newTreeCore[0].comment).to.equal('');
});
it('non Existing Path', () => {
expect(() => setCommentForPath(treeCore, 'src/utils/wrongfolder', 'NEW COMMENT!')).to.throw();
});
it('Invalid address', () => {
expect(() => setCommentForPath(treeCore, '///ds//', 'NEW COMMENT!')).to.throw();
});
});