37 lines
785 B
Go
37 lines
785 B
Go
|
|
package webapp
|
||
|
|
|
||
|
|
import (
|
||
|
|
"net/http"
|
||
|
|
"net/http/httptest"
|
||
|
|
"strings"
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestHandlerServesIndex(t *testing.T) {
|
||
|
|
req := httptest.NewRequest(http.MethodGet, "/", nil)
|
||
|
|
rec := httptest.NewRecorder()
|
||
|
|
|
||
|
|
Handler().ServeHTTP(rec, req)
|
||
|
|
|
||
|
|
if rec.Code != http.StatusOK {
|
||
|
|
t.Fatalf("status = %d", rec.Code)
|
||
|
|
}
|
||
|
|
if !strings.Contains(rec.Body.String(), "Interview practice") {
|
||
|
|
t.Fatal("expected app shell content")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestHandlerServesAsset(t *testing.T) {
|
||
|
|
req := httptest.NewRequest(http.MethodGet, "/assets/app.js", nil)
|
||
|
|
rec := httptest.NewRecorder()
|
||
|
|
|
||
|
|
Handler().ServeHTTP(rec, req)
|
||
|
|
|
||
|
|
if rec.Code != http.StatusOK {
|
||
|
|
t.Fatalf("status = %d", rec.Code)
|
||
|
|
}
|
||
|
|
if !strings.Contains(rec.Body.String(), "diagnostic-sessions") {
|
||
|
|
t.Fatal("expected app script content")
|
||
|
|
}
|
||
|
|
}
|