|
| 1 | +package create |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/stretchr/testify/assert" |
| 7 | +) |
| 8 | + |
| 9 | +func TestNormalizeLanguage(t *testing.T) { |
| 10 | + tests := []struct { |
| 11 | + input string |
| 12 | + expected string |
| 13 | + }{ |
| 14 | + {"ts", "typescript"}, |
| 15 | + {"py", "python"}, |
| 16 | + {"typescript", "typescript"}, |
| 17 | + {"invalid", "invalid"}, |
| 18 | + } |
| 19 | + |
| 20 | + for _, tt := range tests { |
| 21 | + t.Run(tt.input, func(t *testing.T) { |
| 22 | + got := NormalizeLanguage(tt.input) |
| 23 | + assert.Equal(t, tt.expected, got, "NormalizeLanguage(%q) should return %q, got %q", tt.input, tt.expected, got) |
| 24 | + }) |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +func TestTemplates(t *testing.T) { |
| 29 | + // Should have at least one template |
| 30 | + assert.NotEmpty(t, Templates, "Templates map should not be empty") |
| 31 | + |
| 32 | + // Sample app should exist |
| 33 | + sampleApp, exists := Templates["sample-app"] |
| 34 | + assert.True(t, exists, "sample-app template should exist") |
| 35 | + |
| 36 | + // Sample app should have required fields |
| 37 | + assert.NotEmpty(t, sampleApp.Name, "Template should have a name") |
| 38 | + assert.NotEmpty(t, sampleApp.Description, "Template should have a description") |
| 39 | + assert.NotEmpty(t, sampleApp.Languages, "Template should support at least one language") |
| 40 | + |
| 41 | + // Should support both typescript and python |
| 42 | + assert.Contains(t, sampleApp.Languages, Language(LanguageTypeScript), "sample-app should support typescript") |
| 43 | + assert.Contains(t, sampleApp.Languages, Language(LanguagePython), "sample-app should support python") |
| 44 | +} |
0 commit comments