(t *testing.T)
| 270 | } |
| 271 | |
| 272 | func 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 | |
| 292 | func BenchmarkFormatJavaScriptForYAML(b *testing.B) { |
| 293 | script := `const github = require('@actions/github'); |
nothing calls this directly
no test coverage detected