-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create getConditionalClasses.test.ts
- Loading branch information
1 parent
1aa3a58
commit 4c5d71d
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
packages/lib/src/utils/__tests__/getConditionalClasses.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" }); | ||
}); | ||
}); |