|
1 | 1 | #!/usr/bin/env bats |
2 | 2 |
|
3 | 3 | load ../test_helper |
4 | | -load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh" |
5 | | -load ../../lib/helpers |
6 | | -load ../../lib/utilities |
7 | | -load ../../lib/search |
8 | | - |
9 | | -cite _about _param _example _group _author _version |
| 4 | +load ../test_helper_libs |
10 | 5 |
|
11 | 6 | function local_setup { |
12 | 7 | setup_test_fixture |
13 | 8 | } |
14 | 9 |
|
15 | | -function has_match() { |
16 | | - $(_bash-it-array-contains-element ${@}) && echo "has" "$1" |
17 | | -} |
18 | | - |
19 | | -function item_enabled() { |
20 | | - $(_bash-it-component-item-is-enabled ${@}) && echo "$1" "$2" "is enabled" |
21 | | -} |
22 | | - |
23 | | -function item_disabled() { |
24 | | - $(_bash-it-component-item-is-disabled ${@}) && echo "$1" "$2" "is disabled" |
25 | | -} |
26 | | - |
27 | 10 | @test "_bash-it-component-item-is-enabled() - for a disabled item" { |
28 | | - run item_enabled aliases svn |
29 | | - assert_line -n 0 '' |
| 11 | + run _bash-it-component-item-is-enabled aliases svn |
| 12 | + assert_failure |
30 | 13 | } |
31 | 14 |
|
32 | 15 | @test "_bash-it-component-item-is-enabled() - for an enabled/disabled item" { |
33 | 16 | run bash-it enable alias svn |
34 | 17 | assert_line -n 0 'svn enabled with priority 150.' |
35 | 18 |
|
36 | | - run item_enabled alias svn |
37 | | - assert_line -n 0 'alias svn is enabled' |
| 19 | + run _bash-it-component-item-is-enabled alias svn |
| 20 | + assert_success |
| 21 | + run _bash-it-component-item-is-disabled alias svn |
| 22 | + assert_failure |
38 | 23 |
|
39 | 24 | run bash-it disable alias svn |
40 | 25 | assert_line -n 0 'svn disabled.' |
41 | 26 |
|
42 | | - run item_enabled alias svn |
43 | | - assert_line -n 0 '' |
| 27 | + run _bash-it-component-item-is-enabled alias svn |
| 28 | + assert_failure |
| 29 | + run _bash-it-component-item-is-disabled alias svn |
| 30 | + assert_success |
44 | 31 | } |
45 | 32 |
|
46 | 33 | @test "_bash-it-component-item-is-disabled() - for a disabled item" { |
47 | | - run item_disabled alias svn |
48 | | - assert_line -n 0 'alias svn is disabled' |
| 34 | + run _bash-it-component-item-is-disabled alias svn |
| 35 | + assert_success |
49 | 36 | } |
50 | 37 |
|
51 | 38 | @test "_bash-it-component-item-is-disabled() - for an enabled/disabled item" { |
52 | 39 | run bash-it enable alias svn |
53 | 40 | assert_line -n 0 'svn enabled with priority 150.' |
54 | 41 |
|
55 | | - run item_disabled alias svn |
56 | | - assert_line -n 0 '' |
| 42 | + run _bash-it-component-item-is-disabled alias svn |
| 43 | + assert_failure |
| 44 | + run _bash-it-component-item-is-enabled alias svn |
| 45 | + assert_success |
57 | 46 |
|
58 | 47 | run bash-it disable alias svn |
59 | 48 | assert_line -n 0 'svn disabled.' |
60 | 49 |
|
61 | | - run item_disabled alias svn |
62 | | - assert_line -n 0 'alias svn is disabled' |
| 50 | + run _bash-it-component-item-is-disabled alias svn |
| 51 | + assert_success |
| 52 | + run _bash-it-component-item-is-enabled alias svn |
| 53 | + assert_failure |
63 | 54 | } |
64 | 55 |
|
65 | 56 | @test "_bash-it-array-contains-element() - when match is found, and is the first" { |
66 | 57 | declare -a fruits=(apple pear orange mandarin) |
67 | | - run has_match apple "${fruits[@]}" |
68 | | - assert_line -n 0 'has apple' |
| 58 | + run _bash-it-array-contains-element apple "${fruits[@]}" |
| 59 | + assert_success |
69 | 60 | } |
70 | 61 |
|
71 | 62 | @test "_bash-it-array-contains-element() - when match is found, and is the last" { |
72 | 63 | declare -a fruits=(apple pear orange mandarin) |
73 | | - run has_match mandarin "${fruits[@]}" |
74 | | - assert_line -n 0 'has mandarin' |
| 64 | + run _bash-it-array-contains-element mandarin "${fruits[@]}" |
| 65 | + assert_success |
75 | 66 | } |
76 | 67 |
|
77 | 68 | @test "_bash-it-array-contains-element() - when match is found, and is in the middle" { |
78 | 69 | declare -a fruits=(apple pear orange mandarin) |
79 | | - run has_match pear "${fruits[@]}" |
80 | | - assert_line -n 0 'has pear' |
| 70 | + run _bash-it-array-contains-element pear "${fruits[@]}" |
| 71 | + assert_success |
81 | 72 | } |
82 | 73 |
|
83 | 74 | @test "_bash-it-array-contains-element() - when match is found, and it has spaces" { |
84 | 75 | declare -a fruits=(apple pear orange mandarin "yellow watermelon") |
85 | | - run has_match "yellow watermelon" "${fruits[@]}" |
86 | | - assert_line -n 0 'has yellow watermelon' |
| 76 | + run _bash-it-array-contains-element "yellow watermelon" "${fruits[@]}" |
| 77 | + assert_success |
87 | 78 | } |
88 | 79 |
|
89 | 80 | @test "_bash-it-array-contains-element() - when match is not found" { |
90 | 81 | declare -a fruits=(apple pear orange mandarin) |
91 | | - run has_match xyz "${fruits[@]}" |
92 | | - assert_line -n 0 '' |
| 82 | + run _bash-it-array-contains-element xyz "${fruits[@]}" |
| 83 | + assert_failure |
93 | 84 | } |
0 commit comments