resume/tests/unit/includes-test.sh

49 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# =====================================================================
# includes-test.sh - Test the includes.js functionality
# =====================================================================
# This script checks if the includes.js file is valid JavaScript
# =====================================================================
echo "=== Testing includes.js ==="
# Path to the includes.js file
INCLUDES_JS="docker/resume/includes.js"
# Check if the file exists
if [ ! -f "$INCLUDES_JS" ]; then
echo "❌ File not found: $INCLUDES_JS"
exit 1
fi
echo "✅ File exists: $INCLUDES_JS"
# Check if the file is valid JavaScript using node
if command -v node &> /dev/null; then
echo "Checking if the file is valid JavaScript..."
if node --check "$INCLUDES_JS" &> /dev/null; then
echo "✅ File is valid JavaScript"
else
echo "❌ File contains JavaScript syntax errors"
node --check "$INCLUDES_JS"
exit 1
fi
else
echo "⚠️ Node.js not found, skipping JavaScript syntax check"
fi
# Check for required functions
echo "Checking for required functions..."
REQUIRED_FUNCTIONS=("includeHTML")
for func in "${REQUIRED_FUNCTIONS[@]}"; do
if grep -q "function $func" "$INCLUDES_JS"; then
echo "✅ Required function found: $func"
else
echo "❌ Required function not found: $func"
exit 1
fi
done
echo "=== includes.js Test Completed Successfully ==="
exit 0