(t *testing.T)
| 64 | } |
| 65 | } |
| 66 | func TestDefaultHTMLDoc_NoPath(t *testing.T) { |
| 67 | currentMode := CurrentDevMode |
| 68 | CurrentDevMode = DevBundleMode |
| 69 | bodyContent := "<test>This is a thing here<test>" |
| 70 | headContent := `<script id="thing"> {} </script>` |
| 71 | doc := defaultHTMLDoc(fmt.Sprintf("<head>%s</head><body>%s</body>", headContent, bodyContent)) |
| 72 | hasMeta := false |
| 73 | hasHeadContent := false |
| 74 | for _, h := range doc.Head { |
| 75 | if strings.Contains(h, "meta") { |
| 76 | hasMeta = true |
| 77 | } |
| 78 | if strings.Contains(h, headContent) { |
| 79 | hasHeadContent = true |
| 80 | } |
| 81 | } |
| 82 | if !hasMeta { |
| 83 | t.Error("default doc does not contain meta tag") |
| 84 | } |
| 85 | if !hasHeadContent { |
| 86 | t.Error("expected override head to exist in final body") |
| 87 | } |
| 88 | hasNewBody := false |
| 89 | hasDebugClass := false |
| 90 | for _, h := range doc.Body { |
| 91 | if strings.Contains(h, bodyContent) { |
| 92 | hasNewBody = true |
| 93 | } |
| 94 | if strings.Contains(h, `class="debug"`) { |
| 95 | hasDebugClass = true |
| 96 | } |
| 97 | } |
| 98 | if !hasNewBody { |
| 99 | t.Error("expected override body to exist in final body") |
| 100 | } |
| 101 | if !hasDebugClass { |
| 102 | t.Error("expected debug class to be present during debug mode") |
| 103 | } |
| 104 | CurrentDevMode = currentMode |
| 105 | } |
| 106 | type mockResponseWriter struct { |
| 107 | mockWriteHeader func(statusCode int) |
| 108 | mockWrite func([]byte) (int, error) |
nothing calls this directly
no test coverage detected