Skip to content

Commit 5f6b76d

Browse files
committed
fix type
1 parent 0a37641 commit 5f6b76d

13 files changed

Lines changed: 59 additions & 59 deletions

File tree

packages/error/src/__tests__/invariant.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ describe('invariant', () => {
2727
})
2828

2929
test('works with falsy values as condition', () => {
30+
// @ts-expect-error - we want to test the falsy values
3031
expect(() => invariant(1 === 2, 'Error')).toThrow()
3132
expect(() => invariant(Boolean(''), 'Error')).toThrow()
3233
})
3334
})
34-

packages/schema/src/__tests__/validators.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ describe('isValidObjectSchema', () => {
134134
})
135135

136136
test('returns false for invalid object schema', () => {
137-
expect(isValidObjectSchema({ type: 'array', items: {} })).toBe(false)
137+
expect(
138+
isValidObjectSchema({ type: 'array', items: { type: 'string' } })
139+
).toBe(false)
138140
})
139141
})
140142

@@ -154,4 +156,3 @@ describe('isValidSchema', () => {
154156
expect(isValidSchema({ invalid: true } as any)).toBe(false)
155157
})
156158
})
157-

packages/storage/src/__tests__/useStorage.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ describe('useStorage', () => {
162162

163163
const getStorage = () => ({
164164
getItem: (key: string) => cache.get(key),
165-
setItem: (key: string, value: any) => cache.set(key, value),
165+
setItem: (key: string, value: any) => {
166+
cache.set(key, value)
167+
},
166168
})
167169

168170
const { result } = renderHook(() => useStorage(getStorage, 'counter', 0))
@@ -219,7 +221,9 @@ describe('useStorage', () => {
219221

220222
const getStorage = () => ({
221223
getItem: (key: string) => cache.get(key),
222-
setItem: (key: string, value: any) => cache.set(key, value),
224+
setItem: (key: string, value: any) => {
225+
cache.set(key, value)
226+
},
223227
})
224228

225229
const { result } = renderHook(() => useStorage(getStorage, 'counter', 0))
@@ -259,7 +263,9 @@ describe('useStorage', () => {
259263

260264
const getStorage = () => ({
261265
getItem: (key: string) => cache.get(key),
262-
setItem: (key: string, value: any) => cache.set(key, value),
266+
setItem: (key: string, value: any) => {
267+
cache.set(key, value)
268+
},
263269
})
264270

265271
const { result } = renderHook(() =>

packages/style/src/plugins/__tests__/customProperty.test.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@ import { describe, test, expect, vi } from 'vitest'
33
import customPropertyPlugin from '../customProperty'
44

55
describe('customPropertyPlugin', () => {
6-
const mockContext = {
6+
const context = {
77
mergeStyle: (target: any, source: any) => Object.assign(target, source),
88
createNode: vi.fn(),
9-
props: {},
10-
}
9+
props: { style: {} },
10+
devMode: false,
11+
} as const
1112

1213
test('resolves custom properties to style objects', () => {
1314
const plugin = customPropertyPlugin({
1415
size: (value: number) => ({ width: value, height: value }),
1516
})
1617

17-
const result = plugin({ size: 100 } as any, mockContext as any)
18+
const result = plugin({ size: 100 }, context)
1819

1920
expect(result.width).toBe(100)
2021
expect(result.height).toBe(100)
@@ -25,9 +26,9 @@ describe('customPropertyPlugin', () => {
2526
spacing: (value: number) => ({ padding: value, margin: value }),
2627
})
2728

28-
const result = plugin({ spacing: 10 } as any, mockContext as any)
29+
const result = plugin({ spacing: 10 }, context)
2930

30-
expect(result.spacing).toBeUndefined()
31+
expect('spacing' in result).toBeFalsy()
3132
expect(result.padding).toBe(10)
3233
expect(result.margin).toBe(10)
3334
})
@@ -37,7 +38,7 @@ describe('customPropertyPlugin', () => {
3738
padding: (value: number) => ({ padding: value * 2 }),
3839
})
3940

40-
const result = plugin({ padding: 10 } as any, mockContext as any)
41+
const result = plugin({ padding: 10 }, context)
4142

4243
expect(result.padding).toBe(20)
4344
})
@@ -50,23 +51,20 @@ describe('customPropertyPlugin', () => {
5051
const result = plugin(
5152
{
5253
':hover': { size: 50 },
53-
} as any,
54-
mockContext as any
54+
},
55+
context
5556
)
5657

57-
expect(result[':hover'].width).toBe(50)
58-
expect(result[':hover'].height).toBe(50)
58+
expect(result[':hover']?.width).toBe(50)
59+
expect(result[':hover']?.height).toBe(50)
5960
})
6061

6162
test('passes through non-custom properties', () => {
6263
const plugin = customPropertyPlugin({
6364
size: (value: number) => ({ width: value }),
6465
})
6566

66-
const result = plugin(
67-
{ size: 100, color: 'red' } as any,
68-
mockContext as any
69-
)
67+
const result = plugin({ size: 100, color: 'red' }, context)
7068

7169
expect(result.color).toBe('red')
7270
expect(result.width).toBe(100)
@@ -78,11 +76,10 @@ describe('customPropertyPlugin', () => {
7876
spacing: (value: number) => ({ padding: value }),
7977
})
8078

81-
const result = plugin({ size: 100, spacing: 10 } as any, mockContext as any)
79+
const result = plugin({ size: 100, spacing: 10 }, context)
8280

8381
expect(result.width).toBe(100)
8482
expect(result.height).toBe(100)
8583
expect(result.padding).toBe(10)
8684
})
8785
})
88-

packages/style/src/plugins/__tests__/embedded.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('embeddedPlugin', () => {
5858

5959
const result = plugin(style as any, mockContext as any)
6060

61-
expect(typeof result[':hover'].animationName).toBe('string')
61+
expect(typeof result[':hover']?.animationName).toBe('string')
6262
expect(mockContext.createNode).toHaveBeenCalled()
6363
})
6464

@@ -95,4 +95,3 @@ describe('embeddedPlugin', () => {
9595
expect(mockContext.createNode).not.toHaveBeenCalled()
9696
})
9797
})
98-

packages/style/src/plugins/__tests__/enforceLonghand.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,9 @@ describe('enforceLonghandPlugin', () => {
112112
}
113113

114114
const result = plugin(style as any)
115-
const hoverKeys = Object.keys(result[':hover'])
115+
const hoverKeys = Object.keys(result[':hover']!)
116116

117117
expect(hoverKeys[0]).toBe('padding')
118118
expect(hoverKeys[1]).toBe('paddingTop')
119119
})
120120
})
121-

packages/style/src/plugins/__tests__/fallbackValue.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ describe('fallbackValuePlugin', () => {
2828
{
2929
property: ['width'],
3030
fallback: (value) =>
31-
value === 'fit-content' ? ['-webkit-fit-content', 'fit-content'] : undefined,
31+
value === 'fit-content'
32+
? ['-webkit-fit-content', 'fit-content']
33+
: undefined,
3234
},
3335
])
3436

@@ -82,7 +84,9 @@ describe('fallbackValuePlugin', () => {
8284
{
8385
property: ['width'],
8486
fallback: (value) =>
85-
value === 'max-content' ? ['-webkit-max-content', 'max-content'] : undefined,
87+
value === 'max-content'
88+
? ['-webkit-max-content', 'max-content']
89+
: undefined,
8690
},
8791
])
8892

@@ -92,7 +96,7 @@ describe('fallbackValuePlugin', () => {
9296

9397
const result = plugin(style as any, mockContext as any)
9498

95-
expect(result[':hover'].width).toContain('var(')
99+
expect(result[':hover']?.width).toContain('var(')
96100
})
97101

98102
test('handles multiple fallback rules', () => {
@@ -119,4 +123,3 @@ describe('fallbackValuePlugin', () => {
119123
expect(mockContext.createNode).toHaveBeenCalledTimes(2)
120124
})
121125
})
122-

packages/style/src/plugins/__tests__/prefixer.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('prefixerPlugin', () => {
4949

5050
const result = plugin(style as any)
5151

52-
expect(result.WebkitColor).toBeUndefined()
52+
expect('WebkitColor' in result).toBeFalsy()
5353
expect(result.color).toBe('red')
5454
})
5555

@@ -63,7 +63,7 @@ describe('prefixerPlugin', () => {
6363
const result = plugin(style as any)
6464

6565
expect(result.WebkitAppearance).toBe('none')
66-
expect(result[':hover'].WebkitUserSelect).toBe('text')
66+
expect(result[':hover']?.WebkitUserSelect).toBe('text')
6767
})
6868

6969
test('prefixes mask properties', () => {
@@ -86,4 +86,3 @@ describe('prefixerPlugin', () => {
8686
expect(result.clipPath).toBe('circle(50%)')
8787
})
8888
})
89-

packages/style/src/plugins/__tests__/pseudoElement.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('pseudoElementPlugin', () => {
8282
const result = plugin(style as any, mockContext as any)
8383

8484
// The ::before inside :hover should be processed
85-
expect(result[':hover']['::before']).toBeUndefined()
85+
expect(result[':hover']?.['::before']).toBeUndefined()
8686
expect(mockContext.createNode).toHaveBeenCalled()
8787
})
8888

packages/style/src/plugins/__tests__/responsiveValue.test.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, test, expect } from 'vitest'
22

3-
import responsiveValuePlugin from '../responsiveValue'
3+
import responsiveValuePlugin, { responsiveValue } from '../responsiveValue'
44

55
describe('responsiveValuePlugin', () => {
66
const mediaQueries = [
@@ -11,7 +11,7 @@ describe('responsiveValuePlugin', () => {
1111

1212
test('expands array values to media queries', () => {
1313
const plugin = responsiveValuePlugin(mediaQueries)
14-
const result = plugin({ fontSize: [16, 18, 20, 24] })
14+
const result = plugin({ fontSize: responsiveValue([16, 18, 20, 24]) })
1515

1616
expect(result.fontSize).toBe(16)
1717
expect(result['@media (min-width: 480px)']).toEqual({ fontSize: 18 })
@@ -21,7 +21,7 @@ describe('responsiveValuePlugin', () => {
2121

2222
test('first value is default', () => {
2323
const plugin = responsiveValuePlugin(mediaQueries)
24-
const result = plugin({ padding: [8, 16] })
24+
const result = plugin({ padding: responsiveValue([8, 16]) })
2525

2626
expect(result.padding).toBe(8)
2727
expect(result['@media (min-width: 480px)']).toEqual({ padding: 16 })
@@ -50,17 +50,17 @@ describe('responsiveValuePlugin', () => {
5050
':hover': { fontSize: [14, 16] },
5151
} as any)
5252

53-
expect(result[':hover'].fontSize).toBe(14)
54-
expect(result[':hover']['@media (min-width: 480px)']).toEqual({
53+
expect(result[':hover']?.fontSize).toBe(14)
54+
expect(result[':hover']?.['@media (min-width: 480px)']).toEqual({
5555
fontSize: 16,
5656
})
5757
})
5858

5959
test('handles multiple responsive properties', () => {
6060
const plugin = responsiveValuePlugin(mediaQueries)
6161
const result = plugin({
62-
fontSize: [16, 18],
63-
padding: [8, 12],
62+
fontSize: responsiveValue([16, 18]),
63+
padding: responsiveValue([8, 12]),
6464
})
6565

6666
expect(result.fontSize).toBe(16)
@@ -73,12 +73,11 @@ describe('responsiveValuePlugin', () => {
7373

7474
test('limits to number of media queries', () => {
7575
const plugin = responsiveValuePlugin(['@media (min-width: 480px)'])
76-
const result = plugin({ fontSize: [16, 18, 20, 24] })
76+
const result = plugin({ fontSize: responsiveValue([16, 18, 20, 24]) })
7777

7878
// Only first media query value used
7979
expect(result.fontSize).toBe(16)
8080
expect(result['@media (min-width: 480px)']).toEqual({ fontSize: 18 })
8181
expect(result['@media (min-width: 768px)']).toBeUndefined()
8282
})
8383
})
84-

0 commit comments

Comments
 (0)