Skip to content

Commit 757717d

Browse files
committed
test: tighten vacuous assertions in cacache and spinner
- cacache.test.mts: drop toBeDefined on cacache.rm/ls — subsequent typeof check on rm.entry/ls.stream already enforces the namespaces exist - spinner.test.mts: consolidate 4 near-duplicate 'should accept X theme' tests into one it.each; strengthen getCliSpinners socket test to assert frames is an array and interval is a number instead of just toBeDefined
1 parent cd9beac commit 757717d

2 files changed

Lines changed: 10 additions & 23 deletions

File tree

test/unit/cacache.test.mts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ describe('cacache', () => {
4444
expect(typeof cacache.get).toBe('function')
4545
expect(typeof cacache.put).toBe('function')
4646
// rm and ls are namespaces with methods like rm.entry, rm.all, ls.stream
47-
expect(cacache.rm).toBeDefined()
48-
expect(cacache.ls).toBeDefined()
4947
expect(typeof cacache.rm.entry).toBe('function')
5048
expect(typeof cacache.ls.stream).toBe('function')
5149
})

test/unit/spinner.test.mts

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -756,33 +756,22 @@ describe('spinner', () => {
756756
})
757757

758758
describe('Theme handling', () => {
759-
it('should accept theme as string name', () => {
760-
const spinner = Spinner({ theme: 'socket' })
761-
expect(spinner).toBeDefined()
762-
})
763-
764-
it('should accept theme lush', () => {
765-
const spinner = Spinner({ theme: 'lush' })
766-
expect(spinner).toBeDefined()
767-
})
768-
769-
it('should accept theme sunset', () => {
770-
const spinner = Spinner({ theme: 'sunset' })
771-
expect(spinner).toBeDefined()
772-
})
773-
774-
it('should accept theme ultra', () => {
775-
const spinner = Spinner({ theme: 'ultra' })
776-
expect(spinner).toBeDefined()
777-
})
759+
it.each(['socket', 'lush', 'sunset', 'ultra'] as const)(
760+
'should accept %s theme name without throwing and return a spinner with methods',
761+
themeName => {
762+
const spinner = Spinner({ theme: themeName })
763+
expect(typeof spinner.start).toBe('function')
764+
expect(typeof spinner.stop).toBe('function')
765+
},
766+
)
778767
})
779768

780769
describe('getCliSpinners', () => {
781770
it('should return socket custom spinner', () => {
782771
const socket = getCliSpinners('socket')
783772
expect(socket).toBeDefined()
784-
expect(socket!.frames).toBeDefined()
785-
expect(socket!.interval).toBeDefined()
773+
expect(Array.isArray(socket!.frames)).toBe(true)
774+
expect(typeof socket!.interval).toBe('number')
786775
})
787776

788777
it('should return undefined for non-existent spinner', () => {

0 commit comments

Comments
 (0)