Skip to content

Commit 3dce201

Browse files
committed
test(spinner): enable withSpinner state restoration tests
Removed .todo() markers from 10 integration tests that verify withSpinner and withSpinnerSync correctly restore color and shimmer state. Tests now pass after setShimmer bug fix. Tests enabled: - withSpinner: 6 tests (color restore, named colors, shimmer, disable shimmer, no options, error handling) - withSpinnerSync: 4 tests (color restore, shimmer, no options, error handling) All 11 tests now passing. Closes #14
1 parent d20ad4b commit 3dce201

1 file changed

Lines changed: 41 additions & 50 deletions

File tree

test/spinner.test.ts

Lines changed: 41 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ describe('spinner', () => {
1717
})
1818

1919
describe('withSpinner', () => {
20-
// Note: These tests require full logger context which isn't available in unit test env
21-
// They are marked as todo until proper integration test setup is implemented
22-
// Tracked in: https://github.com/SocketDev/socket-lib/issues/14
23-
it.todo('should restore color after operation', async () => {
20+
it('should restore color after operation', async () => {
2421
const spinner = Spinner({ color: [140, 82, 255] })
2522
const originalColor = spinner.color
2623

@@ -40,30 +37,27 @@ describe('spinner', () => {
4037
expect(spinner.color).toEqual(originalColor)
4138
})
4239

43-
it.todo(
44-
'should restore color after operation with named color',
45-
async () => {
46-
const spinner = Spinner({ color: 'cyan' })
47-
const originalColor = spinner.color
40+
it('should restore color after operation with named color', async () => {
41+
const spinner = Spinner({ color: 'cyan' })
42+
const originalColor = spinner.color
4843

49-
await withSpinner({
50-
message: 'Testing...',
51-
operation: async () => {
52-
// Just verify operation runs
53-
expect(true).toBe(true)
54-
},
55-
spinner,
56-
withOptions: {
57-
color: 'red',
58-
},
59-
})
44+
await withSpinner({
45+
message: 'Testing...',
46+
operation: async () => {
47+
// Just verify operation runs
48+
expect(true).toBe(true)
49+
},
50+
spinner,
51+
withOptions: {
52+
color: 'red',
53+
},
54+
})
6055

61-
// After operation, color should be restored
62-
expect(spinner.color).toEqual(originalColor)
63-
},
64-
)
56+
// After operation, color should be restored
57+
expect(spinner.color).toEqual(originalColor)
58+
})
6559

66-
it.todo('should restore shimmer state after operation', async () => {
60+
it('should restore shimmer state after operation', async () => {
6761
const spinner = Spinner({ shimmer: { dir: 'ltr', speed: 0.5 } })
6862
const originalShimmer = spinner.shimmerState
6963

@@ -84,29 +78,26 @@ describe('spinner', () => {
8478
expect(spinner.shimmerState?.speed).toBe(originalShimmer?.speed)
8579
})
8680

87-
it.todo(
88-
'should disable shimmer after operation if it was disabled before',
89-
async () => {
90-
const spinner = Spinner() // No shimmer
81+
it('should disable shimmer after operation if it was disabled before', async () => {
82+
const spinner = Spinner() // No shimmer
9183

92-
await withSpinner({
93-
message: 'Testing...',
94-
operation: async () => {
95-
// During operation, shimmer should be enabled
96-
expect(spinner.shimmerState).toBeDefined()
97-
},
98-
spinner,
99-
withOptions: {
100-
shimmer: { dir: 'ltr' },
101-
},
102-
})
84+
await withSpinner({
85+
message: 'Testing...',
86+
operation: async () => {
87+
// During operation, shimmer should be enabled
88+
expect(spinner.shimmerState).toBeDefined()
89+
},
90+
spinner,
91+
withOptions: {
92+
shimmer: { dir: 'ltr' },
93+
},
94+
})
10395

104-
// After operation, shimmer should be disabled again
105-
expect(spinner.shimmerState).toBeUndefined()
106-
},
107-
)
96+
// After operation, shimmer should be disabled again
97+
expect(spinner.shimmerState).toBeUndefined()
98+
})
10899

109-
it.todo('should work without withOptions', async () => {
100+
it('should work without withOptions', async () => {
110101
const spinner = Spinner({ color: [140, 82, 255] })
111102
const originalColor = spinner.color
112103

@@ -131,7 +122,7 @@ describe('spinner', () => {
131122
expect(result).toBe(42)
132123
})
133124

134-
it.todo('should restore state even if operation throws', async () => {
125+
it('should restore state even if operation throws', async () => {
135126
const spinner = Spinner({ color: [140, 82, 255] })
136127
const originalColor = spinner.color
137128

@@ -154,7 +145,7 @@ describe('spinner', () => {
154145
})
155146

156147
describe('withSpinnerSync', () => {
157-
it.todo('should restore color after operation', () => {
148+
it('should restore color after operation', () => {
158149
const spinner = Spinner({ color: [140, 82, 255] })
159150
const originalColor = spinner.color
160151

@@ -174,7 +165,7 @@ describe('spinner', () => {
174165
expect(spinner.color).toEqual(originalColor)
175166
})
176167

177-
it.todo('should restore shimmer state after operation', () => {
168+
it('should restore shimmer state after operation', () => {
178169
const spinner = Spinner({ shimmer: { dir: 'ltr', speed: 0.5 } })
179170
const originalShimmer = spinner.shimmerState
180171

@@ -195,7 +186,7 @@ describe('spinner', () => {
195186
expect(spinner.shimmerState?.speed).toBe(originalShimmer?.speed)
196187
})
197188

198-
it.todo('should work without withOptions', () => {
189+
it('should work without withOptions', () => {
199190
const spinner = Spinner({ color: [140, 82, 255] })
200191
const originalColor = spinner.color
201192

@@ -211,7 +202,7 @@ describe('spinner', () => {
211202
expect(spinner.color).toEqual(originalColor)
212203
})
213204

214-
it.todo('should restore state even if operation throws', () => {
205+
it('should restore state even if operation throws', () => {
215206
const spinner = Spinner({ color: [140, 82, 255] })
216207
const originalColor = spinner.color
217208

0 commit comments

Comments
 (0)