#!/usr/bin/env bats # test-sm-commands.bats - Unit tests for Scrum Master commands # Requires: bats-core (https://github.com/bats-core/bats-core) # Setup test environment setup() { export TEST_DIR="$(mktemp -d)" cd "$TEST_DIR" # Create test project structure mkdir -p .bmad/{stories,documents} # Source the library if [ -f "${BATS_TEST_DIRNAME}/../utils/bmad-lib.sh" ]; then source "${BATS_TEST_DIRNAME}/../utils/bmad-lib.sh" fi } # Cleanup after tests teardown() { cd / rm -rf "$TEST_DIR" } # ============================================================================ # bmad-lib.sh Tests # ============================================================================ @test "bmad-lib: validate_bmad_project detects missing project" { rmdir .bmad run validate_bmad_project [ "$status" -eq 1 ] [[ "$output" == *"No BMAD project found"* ]] } @test "bmad-lib: validate_bmad_project accepts valid project" { run validate_bmad_project [ "$status" -eq 0 ] } @test "bmad-lib: validate_story_file detects missing required fields" { cat > .bmad/stories/test.yaml < .bmad/stories/test.yaml < test.yaml < .bmad/stories/story1.yaml < .bmad/stories/story2.yaml < .bmad/stories/story3.yaml < .bmad/stories/blocked.yaml < .bmad/stories/aging.yaml < .bmad/stories/pointed1.yaml < .bmad/stories/pointed2.yaml < .bmad/stories/story$i.yaml < .bmad/stories/story4.yaml < .bmad/stories/epic1.yaml < .bmad/stories/epic2.yaml < .bmad/stories/epic3.yaml < .bmad/stories/blocked1.yaml < .bmad/stories/notblocked.yaml < .bmad/stories/assigned1.yaml < .bmad/stories/assigned2.yaml < .bmad/stories/unassigned.yaml < .bmad/stories/perf-$i.yaml < .bmad/documents/project-brief.md < .bmad/documents/prd.yaml < .bmad/stories/integration-$i.yaml <