refactor: use python instead of javascript

This commit is contained in:
Bjarke Sporring
2026-01-05 12:21:48 +01:00
parent e1b8d8418a
commit f11f5a4646
14 changed files with 550 additions and 735 deletions

View File

@@ -86,70 +86,70 @@ if ($featureCommit.Length -lt 10) {
}
# Check that required files exist
if (-not (Test-Path "user-profile.js")) {
Write-Host "[FAIL] user-profile.js not found." -ForegroundColor Red
if (-not (Test-Path "user_profile.py")) {
Write-Host "[FAIL] user_profile.py not found." -ForegroundColor Red
Set-Location ..
exit 1
}
if (-not (Test-Path "user-profile.test.js")) {
Write-Host "[FAIL] user-profile.test.js not found." -ForegroundColor Red
if (-not (Test-Path "test_user_profile.py")) {
Write-Host "[FAIL] test_user_profile.py not found." -ForegroundColor Red
Set-Location ..
exit 1
}
# Check that user-profile.js contains all expected features
$userProfileContent = Get-Content "user-profile.js" -Raw
# Check that user_profile.py contains all expected features
$userProfileContent = Get-Content "user_profile.py" -Raw
# Should have the class
if ($userProfileContent -notmatch "class UserProfile") {
Write-Host "[FAIL] user-profile.js should contain UserProfile class." -ForegroundColor Red
Write-Host "[FAIL] user_profile.py should contain UserProfile class." -ForegroundColor Red
Set-Location ..
exit 1
}
# Should have validation method
if ($userProfileContent -notmatch "validate\(\)") {
Write-Host "[FAIL] user-profile.js should contain validate() method." -ForegroundColor Red
if ($userProfileContent -notmatch "def validate\(") {
Write-Host "[FAIL] user_profile.py should contain validate() method." -ForegroundColor Red
Set-Location ..
exit 1
}
# Should have email format validation (the final fix from commit 3)
if ($userProfileContent -notmatch "includes\('@'\)") {
Write-Host "[FAIL] user-profile.js should contain email format validation." -ForegroundColor Red
if ($userProfileContent -notmatch "'@'.*in.*email|email.*in.*'@'") {
Write-Host "[FAIL] user_profile.py should contain email format validation." -ForegroundColor Red
Write-Host "Hint: Make sure all changes from all 4 commits are included." -ForegroundColor Yellow
Set-Location ..
exit 1
}
# Check that test file has content
$testContent = Get-Content "user-profile.test.js" -Raw
$testContent = Get-Content "test_user_profile.py" -Raw
if ($testContent -notmatch "describe.*UserProfile") {
Write-Host "[FAIL] user-profile.test.js should contain UserProfile tests." -ForegroundColor Red
if ($testContent -notmatch "class.*TestUserProfile") {
Write-Host "[FAIL] test_user_profile.py should contain TestUserProfile tests." -ForegroundColor Red
Set-Location ..
exit 1
}
# Check that we have at least 3 test cases
$testMatches = ([regex]::Matches($testContent, "it\(")).Count
$testMatches = ([regex]::Matches($testContent, "def test_")).Count
if ($testMatches -lt 3) {
Write-Host "[FAIL] user-profile.test.js should contain at least 3 test cases." -ForegroundColor Red
Write-Host "[FAIL] test_user_profile.py should contain at least 3 test cases." -ForegroundColor Red
Set-Location ..
exit 1
}
# Verify that the latest commit contains changes to both files
$filesInLastCommit = git diff-tree --no-commit-id --name-only -r HEAD 2>$null
if ($filesInLastCommit -notcontains "user-profile.js") {
Write-Host "[FAIL] The feature commit should include user-profile.js" -ForegroundColor Red
if ($filesInLastCommit -notcontains "user_profile.py") {
Write-Host "[FAIL] The feature commit should include user_profile.py" -ForegroundColor Red
Set-Location ..
exit 1
}
if ($filesInLastCommit -notcontains "user-profile.test.js") {
Write-Host "[FAIL] The feature commit should include user-profile.test.js" -ForegroundColor Red
if ($filesInLastCommit -notcontains "test_user_profile.py") {
Write-Host "[FAIL] The feature commit should include test_user_profile.py" -ForegroundColor Red
Set-Location ..
exit 1
}