mirror of
https://github.com/outline/outline.git
synced 2026-11-21 13:34:02 +03:00
30 lines
987 B
TypeScript
30 lines
987 B
TypeScript
import { breakpoint } from "./breakpoint";
|
|
|
|
const render = (rules: ReturnType<ReturnType<typeof breakpoint>>) =>
|
|
rules.join("").replace(/\s+/g, " ").trim();
|
|
|
|
describe("breakpoint", () => {
|
|
it("should wrap styles in a min-width media query", () => {
|
|
expect(render(breakpoint("tablet")`color: red;`)).toEqual(
|
|
"@media (min-width: 46.0625em) { color: red; }"
|
|
);
|
|
});
|
|
|
|
it("should not wrap styles when the minimum is zero", () => {
|
|
expect(render(breakpoint("mobile")`color: red;`)).toEqual("color: red;");
|
|
});
|
|
|
|
it("should wrap styles in a range media query", () => {
|
|
expect(render(breakpoint("mobile", "tablet")`color: red;`)).toEqual(
|
|
"@media (min-width: 0em) and (max-width: 46em) { color: red; }"
|
|
);
|
|
});
|
|
|
|
it("should keep prop interpolations", () => {
|
|
const rules = breakpoint("tablet")<{ $color: string }>`
|
|
color: ${(props) => props.$color};
|
|
`;
|
|
expect(rules.some((rule) => typeof rule === "function")).toBe(true);
|
|
});
|
|
});
|