Skip to content

Commit

Permalink
rewrite tests to stop relying on implementation detail
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Dec 4, 2024
1 parent cee18ef commit f9e9ef9
Showing 1 changed file with 25 additions and 37 deletions.
62 changes: 25 additions & 37 deletions packages/react/types/tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
keyframes,
withEmotionCache
} from '@emotion/react'
import { JSX as EmotionJSX } from '@emotion/react/jsx-runtime'
import { CSSInterpolation } from '@emotion/serialize'

declare module '@emotion/react' {
Expand Down Expand Up @@ -225,44 +224,33 @@ const anim1 = keyframes`

// Tests for WithConditionalCSSProp
{
// $ExpectType Interpolation<Theme>
type _HasCssPropAsIntended3 = EmotionJSX.LibraryManagedAttributes<
{},
{
className?: string
}
>['css']
const WithOptionalClassName = (props: { className?: string }) => null
;<WithOptionalClassName />
;<WithOptionalClassName css={{ color: 'hotpink' }} />

// $ExpectType Interpolation<Theme>
type _HasCssPropAsIntended4 = EmotionJSX.LibraryManagedAttributes<
{},
{
className: string
}
>['css']
const WithRequiredClassName = (props: { className: string }) => null
// $ExpectError
;<WithRequiredClassName />
// $ExpectError
;<WithRequiredClassName css={{ color: 'hotpink' }} />

// $ExpectType Interpolation<Theme>
type _HasCssPropAsIntended5 = EmotionJSX.LibraryManagedAttributes<
{},
{
className?: unknown
}
>['css']
const WithOptionalUnknownClassName = (props: { className?: unknown }) => null
;<WithOptionalUnknownClassName />
;<WithOptionalUnknownClassName css={{ color: 'hotpink' }} />

// $ExpectType Interpolation<Theme>
type _HasCssPropAsIntended6 = EmotionJSX.LibraryManagedAttributes<
{},
{
className?: string | Array<string>
}
>['css']
const WithOptionalUnionClassName = (props: {
className?: string | Array<string>
}) => null
;<WithOptionalUnionClassName />
;<WithOptionalUnionClassName css={{ color: 'hotpink' }} />

const WithNoClassName = (props: { foo: string }) => null
;<WithNoClassName />
// $ExpectError
;<WithNoClassName css={{ color: 'hotpink' }} />

// $ExpectType false
type _NoCssPropAsIntended1 =
'css' extends keyof EmotionJSX.LibraryManagedAttributes<
{},
{ className?: undefined }
>
? true
: false
const WithOptionalUndefinedClassName = (props: { foo: string }) => null
;<WithOptionalUndefinedClassName />
// $ExpectError
;<WithOptionalUndefinedClassName css={{ color: 'hotpink' }} />
}

0 comments on commit f9e9ef9

Please sign in to comment.