Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Commit

Permalink
chore(typescript): add more test cases for built in components
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-john committed Jan 9, 2018
1 parent b715929 commit a821469
Showing 1 changed file with 61 additions and 5 deletions.
66 changes: 61 additions & 5 deletions test/glamorous.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -534,17 +534,20 @@ const usePropsAreCssOverrides = (
</div>
)

const BuiltinSingleElement: JSX.Element = <glamorous.Div />;
import { Span } from "../"

const BuiltinSingleElement: JSX.Element = <glamorous.Div display="block" onClick={() => {}} />;
const BuiltinSingleElementNamedExport: JSX.Element = <Span display="block" onClick={() => {}} />;

const BuiltinSingleChild: JSX.Element = (
<glamorous.Div>
<glamorous.Span>Hello, world!</glamorous.Span>
<Span>Hello, world!</Span>
</glamorous.Div>
);

const BuiltinMultipleChild: JSX.Element = (
<glamorous.Div>
<glamorous.Span>Hello,</glamorous.Span>
<Span>Hello,</Span>
<glamorous.Span>world!</glamorous.Span>
</glamorous.Div>
);
Expand All @@ -559,8 +562,61 @@ const BuiltinStyledWithSingleChild: JSX.Element = (
);

const BuiltinStyledWithMultipleChild: JSX.Element = (
<glamorous.Div color='red'>
<glamorous.Div color='red' onClick={() => {}}>
<glamorous.Span>Hello,</glamorous.Span>
<glamorous.Span>world!</glamorous.Span>
<Span>world!</Span>
</glamorous.Div>
);

const CustomStatelessComponent: React.SFC<{}> = (_props) => <div />
class CustomClassComponent extends React.Component<{}, {}> {
render() {
return null
}
}
const CustomGlamorousComponent = glamorous.div()
const CustomGlamorousComponent2 = glamorous('div')()
const CustomGlamorousComponent3 = glamorous(CustomGlamorousComponent)()
const BuiltinStyledComponentChildren: JSX.Element = (
<glamorous.Div height={18} onClick={() => {}}>
{}
<CustomStatelessComponent />
<CustomClassComponent />
<CustomGlamorousComponent />
<CustomGlamorousComponent2 />
<CustomGlamorousComponent3 />
</glamorous.Div>
)
const BuiltinStyledWithPrimitivesChildren: JSX.Element = (
<Div color='red'>
{null}
{false}
{true}
{undefined}
{5}
</Div>
);

const BuiltinStyledWithFragment: JSX.Element = (
<div>
<glamorous.Div color='red' onClick={() => {}}>
<React.Fragment />
</glamorous.Div>
<Span color='red' onClick={() => {}}>
<React.Fragment />
</Span>
</div>
);

const cssProps = {
":active": {
color: "purple"
}
};

const BuiltinStyledWithCSSPseudoProps = (
<div>
<glamorous.A {...cssProps} />
<glamorous.A css={cssProps} />
</div>
);

0 comments on commit a821469

Please sign in to comment.