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

Function TestJavaScriptFormattingConsistency

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

Source from the content-addressed store, hash-verified

270}
271
272func TestJavaScriptFormattingConsistency(t *testing.T) {
273 // Test that both functions produce equivalent output
274 testScript := "const x = 1;\n\nconsole.log(x);\n\nreturn x;"
275
276 // Test FormatJavaScriptForYAML
277 formattedLines := FormatJavaScriptForYAML(testScript)
278 formattedResult := strings.Join(formattedLines, "")
279
280 // Test WriteJavaScriptToYAML
281 var yaml strings.Builder
282 WriteJavaScriptToYAML(&yaml, testScript)
283 writeResult := yaml.String()
284
285 if formattedResult != writeResult {
286 t.Errorf("FormatJavaScriptForYAML and WriteJavaScriptToYAML produce different results")
287 t.Errorf("FormatJavaScriptForYAML: %q", formattedResult)
288 t.Errorf("WriteJavaScriptToYAML: %q", writeResult)
289 }
290}
291
292func BenchmarkFormatJavaScriptForYAML(b *testing.B) {
293 script := `const github = require('@actions/github');

Callers

nothing calls this directly

Calls 4

FormatJavaScriptForYAMLFunction · 0.85
WriteJavaScriptToYAMLFunction · 0.85
StringMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected