MCPcopy Index your code
hub / github.com/github/gh-aw / TestWriteJavaScriptToYAMLProducesValidIndentation

Function TestWriteJavaScriptToYAMLProducesValidIndentation

pkg/workflow/js_test.go:252–270  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

250}
251
252func TestWriteJavaScriptToYAMLProducesValidIndentation(t *testing.T) {
253 script := "const x = 1;\nif (x > 0) {\n console.log('positive');\n}"
254 var yaml strings.Builder
255 WriteJavaScriptToYAML(&yaml, script)
256 result := yaml.String()
257
258 lines := strings.Split(result, "\n")
259 // Remove last empty line from split
260 if lines[len(lines)-1] == "" {
261 lines = lines[:len(lines)-1]
262 }
263
264 // Check that all lines start with proper indentation (12 spaces)
265 for i, line := range lines {
266 if !strings.HasPrefix(line, " ") {
267 t.Errorf("Line %d does not start with proper indentation: %q", i, line)
268 }
269 }
270}
271
272func TestJavaScriptFormattingConsistency(t *testing.T) {
273 // Test that both functions produce equivalent output

Callers

nothing calls this directly

Calls 3

WriteJavaScriptToYAMLFunction · 0.85
StringMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected