Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github actions #381

Merged
merged 19 commits into from
Jul 9, 2021
Merged
Prev Previous commit
Next Next commit
switch to inline snapshot
  • Loading branch information
quantizor committed Jul 9, 2021
commit 471f6b055a8f8aa2a39e5423557a6c1f12092c73
28 changes: 0 additions & 28 deletions test/__snapshots__/toHaveStyleRule.spec.js.snap

This file was deleted.

49 changes: 38 additions & 11 deletions test/toHaveStyleRule.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ it("non-styled", () => {
it("message when rules not found", () => {
expect(() =>
expect(renderer.create(<div />).toJSON()).toHaveStyleRule("color", "black")
).toThrowErrorMatchingSnapshot();
).toThrowErrorMatchingInlineSnapshot(
`"No style rules found on passed Component"`
);
});

it("message when rules not found using options", () => {
Expand All @@ -62,7 +64,10 @@ it("message when rules not found using options", () => {
modifier: ":hover"
}
)
).toThrowErrorMatchingSnapshot();
).toThrowErrorMatchingInlineSnapshot(`
"No style rules found on passed Component using options:
{\\"media\\":\\"(max-width:640px)\\",\\"modifier\\":\\":hover\\"}"
`);
});

it("message when property not found", () => {
Expand All @@ -75,7 +80,14 @@ it("message when property not found", () => {
"background-color",
"black"
)
).toThrowErrorMatchingSnapshot();
).toThrowErrorMatchingInlineSnapshot(`
"\\"Property 'background-color' not found in style rules\\"

Expected
\\"background-color: black\\"
Received:
\\"background-color: undefined\\""
`);
});

it("message when value does not match", () => {
Expand All @@ -88,7 +100,14 @@ it("message when value does not match", () => {
"background",
"red"
);
}).toThrowErrorMatchingSnapshot();
}).toThrowErrorMatchingInlineSnapshot(`
"\\"Value mismatch for property 'background'\\"

Expected
\\"background: red\\"
Received:
\\"background: orange\\""
`);
});

it("non existing", () => {
Expand All @@ -102,7 +121,9 @@ it("non existing", () => {
"background",
"papayawhip"
);
}).toThrowErrorMatchingSnapshot();
}).toThrowErrorMatchingInlineSnapshot(
`"No style rules found on passed Component"`
);
});

it("basic", () => {
Expand Down Expand Up @@ -486,20 +507,26 @@ it("nested with styling", () => {
const Children = styled.span`
background: gray;
`;
const MyComponent = (props) => <Wrapper {...props} />;
const MyComponent = props => <Wrapper {...props} />;
const MyStyledComponent = styled(MyComponent)`
color: red;
`;
const ParentComponent = (props) => (
const ParentComponent = props => (
<MyStyledComponent {...props}>
<Children className="test-class" />
</MyStyledComponent>
);

toHaveStyleRule(<MyStyledComponent />, "color", "red");
toHaveStyleRule(<MyStyledComponent className="test-class" />, "color", "red");
expect(shallow(<ParentComponent/>).find(Children)).toHaveStyleRule("background", "gray");
expect(mount(<ParentComponent/>).find(Children)).toHaveStyleRule("background", "gray");
expect(shallow(<ParentComponent />).find(Children)).toHaveStyleRule(
"background",
"gray"
);
expect(mount(<ParentComponent />).find(Children)).toHaveStyleRule(
"background",
"gray"
);
});

it("empty children", () => {
Expand All @@ -516,10 +543,10 @@ it("empty children", () => {
});

it("custom display name prefix", () => {
const Text = styled.span.withConfig({ displayName: 'Text__sc' })`
const Text = styled.span.withConfig({ displayName: "Text__sc" })`
color: red;
`;
const Comp = styled(Text).withConfig({ displayName: 'Comp__Sub-sc' })`
const Comp = styled(Text).withConfig({ displayName: "Comp__Sub-sc" })`
background: papayawhip;
`;
toHaveStyleRule(<Comp />, "background", "papayawhip");
Expand Down