forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-project-info.test.ts
37 lines (27 loc) · 1.01 KB
/
get-project-info.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
import { getProjectName, getProjectPath } from './get-project-info';
describe('getProjectPath helper', () => {
it('should return the calling dir path', () => {
const mockCallingDir = 'calling/dir';
const expected = `${mockCallingDir}/`;
// Add mock to test condition
process.env.CALLING_DIR = mockCallingDir;
expect(getProjectPath()).toEqual(expected);
// Remove mock to not affect other tests
delete process.env.CALLING_DIR;
});
it('should return the projects absolute path', () => {
const expected = `${process.cwd()}/`;
expect(getProjectPath()).toEqual(expected);
});
});
describe('getProjectName helper', () => {
it('should return the last path segment of the calling dir', () => {
const mockCallingDir = 'calling/dir';
const expected = 'dir';
// Add mock to test condition
process.env.CALLING_DIR = mockCallingDir;
expect(getProjectName()).toEqual(expected);
// Remove mock to not affect other tests
delete process.env.CALLING_DIR;
});
});