#!/bin/bash
# =====================================================================
# theme-test.sh - Test the theme.js functionality
# =====================================================================
# This script checks if the theme.js file is valid JavaScript
# =====================================================================

echo "=== Testing theme.js ==="

# Path to the theme.js file
THEME_JS="docker/resume/theme.js"

# Check if the file exists
if [ ! -f "$THEME_JS" ]; then
    echo "❌ File not found: $THEME_JS"
    exit 1
fi

echo "✅ File exists: $THEME_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 "$THEME_JS" &> /dev/null; then
        echo "✅ File is valid JavaScript"
    else
        echo "❌ File contains JavaScript syntax errors"
        node --check "$THEME_JS"
        exit 1
    fi
else
    echo "⚠️ Node.js not found, skipping JavaScript syntax check"
fi

# Check for theme-related functionality
echo "Checking for theme-related functionality..."
if grep -q "dark" "$THEME_JS" || grep -q "light" "$THEME_JS" || grep -q "theme" "$THEME_JS"; then
    echo "✅ Theme-related functionality found"
else
    echo "❌ No theme-related functionality found"
    exit 1
fi

echo "=== theme.js Test Completed Successfully ==="
exit 0
