-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathget-folder-in-path.test.js
More file actions
50 lines (41 loc) · 1.6 KB
/
get-folder-in-path.test.js
File metadata and controls
50 lines (41 loc) · 1.6 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
44
45
46
47
48
49
50
'use strict'
const t = require('tap')
const resolve = require('path').resolve
const normalize = require('path').normalize
const getFolderInPath = require('./get-folder-in-path')
const dummyLogger = {
log: () => {}
}
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'), dummyLogger)
t.ok(path.endsWith(normalize('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'), dummyLogger)
t.ok(path.endsWith(normalize('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'), dummyLogger)
t.ok(path.endsWith(normalize('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', '/', dummyLogger)
t.same(path, null)
})
t.test('folder is empty', function (t) {
t.plan(1)
const path = getFolderInPath('target_git', resolve(__dirname, '../testfolders/empty'), dummyLogger)
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'), dummyLogger)
t.same(path, null)
})
})