-
Notifications
You must be signed in to change notification settings - Fork 3
/
up.bats
60 lines (42 loc) · 1.27 KB
/
up.bats
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
#!/usr/bin/env bash
load up
@test 'up should jump to the parent directory when called without arguments' {
local -r path=${BATS_TEST_TMPDIR}/src/main/java
mkdir -p "$path"
cd "$path"
up
[[ $PWD == "${BATS_TEST_TMPDIR}/src/main" ]]
}
@test 'up should jump to the parent directory with the given name' {
local -r path=${BATS_TEST_TMPDIR}/src/main/java
mkdir -p "$path"
cd "$path"
up src
[[ $PWD == "${BATS_TEST_TMPDIR}/src" ]]
}
@test 'up should jump to the root directory when called with /' {
cd "${BATS_TEST_TEMPDIR}"
up /
[[ $PWD == / ]]
}
@test 'up should jump to the first parent directory with the given name' {
local -r path=${BATS_TEST_TMPDIR}/java/src/main/java/com/github/helpermethod
mkdir -p "$path"
cd "$path"
up java
[[ $PWD == "${BATS_TEST_TMPDIR}/java/src/main/java" ]]
}
@test 'up should jump to the parent directory with the given name containing whitespace' {
local -r path=${BATS_TEST_TMPDIR}/com/git\ hub/helpermethod
mkdir -p "$path"
cd "$path"
up git\ hub
[[ $PWD == "${BATS_TEST_TMPDIR}/com/git hub" ]]
}
@test 'up should jump to the parent directory with the exact given name' {
local -r path=${BATS_TEST_TMPDIR}/java/build/libs/java-0.0.1-SNAPSHOT
mkdir -p "$path"
cd "$path"
up java
[[ $PWD == "${BATS_TEST_TMPDIR}/java" ]]
}