Skip to content

Commit 59dbaeb

Browse files
normalize suite (#242)
* normalize suite
1 parent 21fc277 commit 59dbaeb

File tree

13 files changed

+12453
-116
lines changed

13 files changed

+12453
-116
lines changed

__tests__/ctrf/helpers.test.ts

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { getEmoji } from '../../src/ctrf/helpers'
2-
import { stripAnsi } from '../../src/ctrf/helpers'
1+
import { getEmoji, normalizeSuite, stripAnsi } from '../../src/ctrf/helpers'
32

43
describe('getEmoji', () => {
54
it('returns the correct emoji for "passed"', () => {
@@ -43,6 +42,46 @@ describe('getEmoji', () => {
4342
})
4443
})
4544

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+
4685
describe('stripAnsi', () => {
4786
it('removes ANSI escape codes from a string', () => {
4887
const ansiString = '\u001b[31mHello\u001b[39m'

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)