Skip to content

Commit

Permalink
Create getConditionalClasses.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
rodleviton committed Nov 17, 2023
1 parent 1aa3a58 commit 4c5d71d
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions packages/lib/src/utils/__tests__/getConditionalClasses.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { getConditionalClasses } from "../getConditionalClasses";

describe("getConditionalClasses", () => {
it("should return an empty object if there are no conditions", () => {
const theme = { conditionals: undefined };

const result = getConditionalClasses({ theme });

expect(result).toEqual({});
});

it("should return empty object if conditons are not met", () => {
const modifiers = ["floating"];
const theme = {
conditionals: [
{
modifiers: "block", // Modifier conditions match defaults above as a string
classes: {
root: "!bg-green-500",
},
},
],
};

const result = getConditionalClasses({ theme, modifiers });

expect(result).toEqual({ root: "!bg-green-500" });
});

it("should return correct classes if conditons are met", () => {
const modifiers = ["block"];
const theme = {
conditionals: [
{
modifiers: "block", // Modifier conditions match defaults above as a string
classes: {
root: "!bg-green-500",
},
},
],
};

const result = getConditionalClasses({ theme, modifiers });

expect(result).toEqual({ root: "!bg-green-500" });
});
});

0 comments on commit 4c5d71d

Please sign in to comment.