-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgetFolderInPath.test.js
More file actions
43 lines (36 loc) · 1.37 KB
/
getFolderInPath.test.js
File metadata and controls
43 lines (36 loc) · 1.37 KB
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
const t = require('tap')
const resolve = require('path').resolve
const getFolderInPath = require('../getFolderInPath')
t.test('getFolderInPath', function (t) {
t.plan(6)
t.test('target folder is in root', function (t) {
t.plan(1)
const path = getFolderInPath('target_git', resolve(__dirname, 'testfolders/root'))
t.ok(path.endsWith('testfolders/root/target_git'))
})
t.test('test folder is in submodule', function (t) {
t.plan(1)
const path = getFolderInPath('target_git', resolve(__dirname, 'testfolders/submodule/moduleA'))
t.ok(path.endsWith('testfolders/submodule/moduleA/target_git'))
})
t.test('test folder is in submodule', function (t) {
t.plan(1)
const path = getFolderInPath('target_git', resolve(__dirname, 'testfolders/recursive/root/sub'))
t.ok(path.endsWith('testfolders/recursive/root/target_git'))
})
t.test('folder is root', function (t) {
t.plan(1)
const path = getFolderInPath('super-special-folder-which-should-never-be-found', '/')
t.same(path, null)
})
t.test('folder is empty', function (t) {
t.plan(1)
const path = getFolderInPath('target_git', resolve(__dirname, 'testfolders/empty'))
t.same(path, null)
})
t.test('folder is empty', function (t) {
t.plan(1)
const path = getFolderInPath('target_git', resolve(__dirname, 'testfolders/file/module/sub'))
t.same(path, null)
})
})