@windyroad/tdd 0.2.2-preview.77 → 0.2.3-preview.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hooks/lib/tdd-gate.sh +18 -1
- package/hooks/test/tdd-gate.bats +26 -0
- package/package.json +1 -1
package/hooks/lib/tdd-gate.sh
CHANGED
|
@@ -21,6 +21,7 @@ tdd_classify_file() {
|
|
|
21
21
|
case "$BASENAME" in
|
|
22
22
|
*.test.ts|*.test.tsx|*.test.js|*.test.jsx) echo "test"; return ;;
|
|
23
23
|
*.spec.ts|*.spec.tsx|*.spec.js|*.spec.jsx) echo "test"; return ;;
|
|
24
|
+
*.feature) echo "test"; return ;;
|
|
24
25
|
esac
|
|
25
26
|
case "$FILE_PATH" in
|
|
26
27
|
*/__tests__/*) echo "test"; return ;;
|
|
@@ -136,7 +137,7 @@ tdd_find_test_for_impl() {
|
|
|
136
137
|
BASENAME=$(basename "$IMPL_PATH")
|
|
137
138
|
|
|
138
139
|
# Strip extension to get stem (e.g., "Hero" from "Hero.tsx")
|
|
139
|
-
# Handle .ts, .tsx, .js, .jsx
|
|
140
|
+
# Handle .ts, .tsx, .js, .jsx, and Cucumber step definitions (.steps.js, .steps.ts, etc.)
|
|
140
141
|
case "$BASENAME" in
|
|
141
142
|
*.tsx) STEM="${BASENAME%.tsx}"; EXT="tsx" ;;
|
|
142
143
|
*.ts) STEM="${BASENAME%.ts}"; EXT="ts" ;;
|
|
@@ -144,6 +145,10 @@ tdd_find_test_for_impl() {
|
|
|
144
145
|
*.js) STEM="${BASENAME%.js}"; EXT="js" ;;
|
|
145
146
|
*) STEM="$BASENAME"; EXT="" ;;
|
|
146
147
|
esac
|
|
148
|
+
# Strip compound step-definition suffixes (e.g. "checkout.steps" -> "checkout")
|
|
149
|
+
case "$STEM" in
|
|
150
|
+
*.steps) STEM="${STEM%.steps}" ;;
|
|
151
|
+
esac
|
|
147
152
|
|
|
148
153
|
local TEST_FILES
|
|
149
154
|
TEST_FILES=$(tdd_get_test_files "$SESSION_ID")
|
|
@@ -182,6 +187,18 @@ tdd_find_test_for_impl() {
|
|
|
182
187
|
esac
|
|
183
188
|
;;
|
|
184
189
|
esac
|
|
190
|
+
|
|
191
|
+
# Cucumber: features/step_definitions/foo.steps.js → features/foo.feature
|
|
192
|
+
# If this impl is inside a step_definitions/ directory, look in the parent for a .feature file
|
|
193
|
+
case "$DIR" in
|
|
194
|
+
*/step_definitions)
|
|
195
|
+
local feature_dir
|
|
196
|
+
feature_dir=$(dirname "$DIR")
|
|
197
|
+
if [ "$tracked_dir" = "$feature_dir" ] && [ "$tracked_base" = "${STEM}.feature" ]; then
|
|
198
|
+
echo "$tracked"; return
|
|
199
|
+
fi
|
|
200
|
+
;;
|
|
201
|
+
esac
|
|
185
202
|
done <<< "$TEST_FILES"
|
|
186
203
|
|
|
187
204
|
# No tracked test found
|
package/hooks/test/tdd-gate.bats
CHANGED
|
@@ -13,6 +13,32 @@ teardown() {
|
|
|
13
13
|
rm -f "/tmp/tdd-setup-active-${TEST_SESSION}"
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
# --- tdd_classify_file: Cucumber .feature files ---
|
|
17
|
+
|
|
18
|
+
@test "classify_file: .feature file is test" {
|
|
19
|
+
result=$(tdd_classify_file "features/checkout.feature")
|
|
20
|
+
[ "$result" = "test" ]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@test "classify_file: nested .feature file is test" {
|
|
24
|
+
result=$(tdd_classify_file "src/features/login.feature")
|
|
25
|
+
[ "$result" = "test" ]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
# --- tdd_find_test_for_impl: Cucumber step_definitions pairing ---
|
|
29
|
+
|
|
30
|
+
@test "find_test_for_impl: step definitions associate with .feature file" {
|
|
31
|
+
tdd_add_test_file "$TEST_SESSION" "features/checkout.feature"
|
|
32
|
+
result=$(tdd_find_test_for_impl "$TEST_SESSION" "features/step_definitions/checkout.steps.js")
|
|
33
|
+
[ "$result" = "features/checkout.feature" ]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@test "find_test_for_impl: step definitions with .steps.ts associate with .feature file" {
|
|
37
|
+
tdd_add_test_file "$TEST_SESSION" "features/login.feature"
|
|
38
|
+
result=$(tdd_find_test_for_impl "$TEST_SESSION" "features/step_definitions/login.steps.ts")
|
|
39
|
+
[ "$result" = "features/login.feature" ]
|
|
40
|
+
}
|
|
41
|
+
|
|
16
42
|
# --- tdd_classify_file ---
|
|
17
43
|
|
|
18
44
|
@test "classify_file: .test.ts is test" {
|