MCPcopy Create free account
hub / github.com/GuyARoss/orbit / TestDefaultHTMLDoc_NoPath

Function TestDefaultHTMLDoc_NoPath

examples/basic-react/orbitgen/orb_test.go:66–105  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

64 }
65}
66func 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}
106type mockResponseWriter struct {
107 mockWriteHeader func(statusCode int)
108 mockWrite func([]byte) (int, error)

Callers

nothing calls this directly

Calls 3

ContainsMethod · 0.80
defaultHTMLDocFunction · 0.70
ErrorMethod · 0.65

Tested by

no test coverage detected