Skip to content

Commit 6ef7ca6

Browse files
committed
test(spinner): add getCliSpinners and stream handling tests
- Import and test getCliSpinners() for socket custom spinner - Add tests for undefined spinner lookup - Add stream handling tests with stderr - Verify spinner style caching behavior Improves spinner test coverage by testing spinner style retrieval and custom stream handling.
1 parent 8729f48 commit 6ef7ca6

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

test/unit/spinner.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212

1313
import {
14+
getCliSpinners,
1415
Spinner,
1516
withSpinner,
1617
withSpinnerSync,
@@ -679,4 +680,40 @@ describe('spinner', () => {
679680
expect(result).toBe(spinner)
680681
})
681682
})
683+
684+
describe('getCliSpinners', () => {
685+
it('should return socket custom spinner', () => {
686+
const socket = getCliSpinners('socket')
687+
expect(socket).toBeDefined()
688+
expect(socket.frames).toBeDefined()
689+
expect(socket.interval).toBeDefined()
690+
})
691+
692+
it('should return undefined for non-existent spinner', () => {
693+
const result = getCliSpinners('non-existent-spinner')
694+
expect(result).toBeUndefined()
695+
})
696+
697+
it('should cache spinner styles', () => {
698+
const first = getCliSpinners()
699+
const second = getCliSpinners()
700+
expect(first).toBe(second)
701+
})
702+
})
703+
704+
describe('Stream handling', () => {
705+
it('should accept custom stream', () => {
706+
const customStream = process.stderr
707+
const spinner = Spinner({ stream: customStream })
708+
expect(spinner).toBeDefined()
709+
})
710+
711+
it('should work with stderr', () => {
712+
const spinner = Spinner({ stream: process.stderr })
713+
spinner.start()
714+
spinner.text('test')
715+
spinner.stop()
716+
expect(spinner.isSpinning).toBe(false)
717+
})
718+
})
682719
})

0 commit comments

Comments
 (0)