|
1 | | -import { getEmoji } from '../../src/ctrf/helpers' |
2 | | -import { stripAnsi } from '../../src/ctrf/helpers' |
| 1 | +import { getEmoji, normalizeSuite, stripAnsi } from '../../src/ctrf/helpers' |
3 | 2 |
|
4 | 3 | describe('getEmoji', () => { |
5 | 4 | it('returns the correct emoji for "passed"', () => { |
@@ -43,6 +42,46 @@ describe('getEmoji', () => { |
43 | 42 | }) |
44 | 43 | }) |
45 | 44 |
|
| 45 | +describe('normalizeSuite', () => { |
| 46 | + it('handles array format (new CTRF format) with default separator', () => { |
| 47 | + const suiteArray = ['string.test.ts', 'String Helpers', 'splitLines'] |
| 48 | + const result = normalizeSuite(suiteArray) |
| 49 | + expect(result).toBe('string.test.ts > String Helpers > splitLines') |
| 50 | + }) |
| 51 | + |
| 52 | + it('handles array format with custom separator', () => { |
| 53 | + const suiteArray = ['suite1', 'suite2', 'suite3'] |
| 54 | + const result = normalizeSuite(suiteArray, ' / ') |
| 55 | + expect(result).toBe('suite1 / suite2 / suite3') |
| 56 | + }) |
| 57 | + |
| 58 | + it('handles string format (legacy CTRF format)', () => { |
| 59 | + const suiteString = 'string.test.ts > String Helpers > splitLines' |
| 60 | + const result = normalizeSuite(suiteString) |
| 61 | + expect(result).toBe('string.test.ts > String Helpers > splitLines') |
| 62 | + }) |
| 63 | + |
| 64 | + it('returns undefined when suite is undefined', () => { |
| 65 | + const result = normalizeSuite(undefined) |
| 66 | + expect(result).toBeUndefined() |
| 67 | + }) |
| 68 | + |
| 69 | + it('handles empty array', () => { |
| 70 | + const result = normalizeSuite([]) |
| 71 | + expect(result).toBe('') |
| 72 | + }) |
| 73 | + |
| 74 | + it('handles single element array', () => { |
| 75 | + const result = normalizeSuite(['suite1']) |
| 76 | + expect(result).toBe('suite1') |
| 77 | + }) |
| 78 | + |
| 79 | + it('handles empty string', () => { |
| 80 | + const result = normalizeSuite('') |
| 81 | + expect(result).toBeUndefined() |
| 82 | + }) |
| 83 | +}) |
| 84 | + |
46 | 85 | describe('stripAnsi', () => { |
47 | 86 | it('removes ANSI escape codes from a string', () => { |
48 | 87 | const ansiString = '\u001b[31mHello\u001b[39m' |
|
0 commit comments