Skip to content

Commit

Permalink
test: add break test
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Aug 22, 2024
1 parent c717049 commit fce36c1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"classnames": "^2.3.1",
"csstype": "^3.1.3",
"rc-util": "^5.35.0",
"stylis": "^4.0.13"
"stylis": "^4.3.3"
},
"devDependencies": {
"@ctrl/tinycolor": "^3.4.0",
Expand Down
34 changes: 34 additions & 0 deletions tests/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -777,4 +777,38 @@ describe('csssinjs', () => {
});
});
});

it('hash & nest style', () => {
const genHashStyle = (): CSSInterpolation => ({
'&': {
a: {
color: 'red',
},
},
});

const Holder = () => {
const [token, hashId] = useCacheToken<DerivativeToken>(theme, [], {
salt: 'test',
});

useStyleRegister({ theme, token, hashId, path: ['holder'] }, () => [
genHashStyle(),
]);

return <div className={classNames('box', hashId)} />;
};

const { unmount } = render(<Holder />);

const styles = Array.from(document.head.querySelectorAll('style'));
expect(styles).toHaveLength(1);

const style = styles[0];
expect(style.innerHTML).toContain(
':where(.css-dev-only-do-not-override-1ldpa3u) a{color:red;}',
);

unmount();
});
});

0 comments on commit fce36c1

Please sign in to comment.