Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/toHaveStyleRule.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const shouldDive = (node) => typeof node.dive === 'function' && typeof node.type

const isTagWithClassName = (node) => node.exists() && node.prop('className') && typeof node.type() === 'string';

const isStyledClass = (className) => /^(\w+(-|_))?sc-/.test(className);
const isStyledClass = (className) => /(_|-)+sc-.+|^sc-/.test(className);

const hasClassName = (node) =>
node.length > 0 &&
Expand Down
9 changes: 9 additions & 0 deletions test/toHaveStyleRule.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,3 +493,12 @@ it('custom display name prefix', () => {
toHaveStyleRule(<Comp />, 'background', 'papayawhip');
toHaveStyleRule(<Comp />, 'color', 'red');
});

it("supports snake case display name prefix", () => {
const Text = styled.span`
color: blue;
`;
Text.styledComponentId = `test-case-${Text.styledComponentId}`;

toHaveStyleRule(<Text />, "color", "blue");
});