TestSpec_PublicAPI_StripANSI validates the documented behavior of StripANSI as described in the package README.md. Specification: "Removes all ANSI/VT100 escape sequences from s. Handles CSI sequences (e.g. \x1b[31m for colors) and other ESC-prefixed sequences." Specification example: colored :=
(t *testing.T)
| 212 | // colored := "\x1b[32mSuccess\x1b[0m" |
| 213 | // plain := stringutil.StripANSI(colored) // "Success" |
| 214 | func TestSpec_PublicAPI_StripANSI(t *testing.T) { |
| 215 | tests := []struct { |
| 216 | name string |
| 217 | input string |
| 218 | expected string |
| 219 | }{ |
| 220 | { |
| 221 | name: "removes CSI color escape sequence (documented example)", |
| 222 | input: "\x1b[32mSuccess\x1b[0m", |
| 223 | expected: "Success", |
| 224 | }, |
| 225 | { |
| 226 | name: "plain string returned unchanged", |
| 227 | input: "plain text", |
| 228 | expected: "plain text", |
| 229 | }, |
| 230 | { |
| 231 | name: "removes red color code (documented \\x1b[31m form)", |
| 232 | input: "\x1b[31mError\x1b[0m", |
| 233 | expected: "Error", |
| 234 | }, |
| 235 | } |
| 236 | |
| 237 | for _, tt := range tests { |
| 238 | t.Run(tt.name, func(t *testing.T) { |
| 239 | result := StripANSI(tt.input) |
| 240 | assert.Equal(t, tt.expected, result, |
| 241 | "StripANSI(%q) should remove ANSI escape sequences", tt.input) |
| 242 | }) |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | // TestSpec_PublicAPI_NormalizeWorkflowName validates the documented behavior of |
| 247 | // NormalizeWorkflowName as described in the package README.md. |