-
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 tests for transformer function
Signed-off-by: Tobias Kuppens Groot <[email protected]>
- Loading branch information
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
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,17 @@ | ||
import { expect } from "chai"; | ||
import { _transform as transform } from "./nameVariableColor.js"; | ||
import { getMockToken } from "../../tests/getMocks.js"; | ||
|
||
describe("[transforms] name transformer nameVariableColor", () => { | ||
it("should transform remove the name `Color` from the token name", () => { | ||
const token = getMockToken({ name: "ColorGrey500" }); | ||
|
||
expect(transform(token, {}, {})).to.equal("Grey500"); | ||
}); | ||
|
||
it("should not change the token name if the name `Color` is not part of the token name", () => { | ||
const token = getMockToken({ name: "Opacity50" }); | ||
|
||
expect(transform(token, {}, {})).to.equal("Opacity50"); | ||
}); | ||
}); |
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,17 @@ | ||
import { expect } from "chai"; | ||
import { getMockToken } from "../../tests/getMocks.js"; | ||
import { _transform as transform } from "./nameVariableDefault.js"; | ||
|
||
describe("[transforms] name transformer nameVariableDefault", () => { | ||
it("should remove the `default` indicator from the token name", () => { | ||
const token = getMockToken({ name: "prefix-color-content-default" }); | ||
|
||
expect(transform(token, {}, {})).to.equal("prefix-color-content"); | ||
}); | ||
|
||
it("should not change a token if the `default` indicator is not part of the token name", () => { | ||
const token = getMockToken({ name: "prefix-color-content" }); | ||
|
||
expect(transform(token, {}, {})).to.equal("prefix-color-content"); | ||
}); | ||
}); |
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,25 @@ | ||
import { expect } from "chai"; | ||
import { getMockToken } from "../../tests/getMocks.js"; | ||
import { _transform as transform } from "./valueColorRgba.js"; | ||
|
||
describe("[transforms] value transformer valueColorRgba", () => { | ||
it("should transform rgba color tokens to use CSS color-mix", () => { | ||
const token = getMockToken({ | ||
name: "CeruleanBlue", | ||
original: { value: "rgba(${color}, ${opacity})" }, | ||
}); | ||
|
||
expect(transform(token, {}, {})).to.equal( | ||
"color-mix(in srgb, ${color} ${opacity}, ${color} 0%)", | ||
); | ||
}); | ||
|
||
it(`should not change color tokens which value doesn't contain rgba values`, () => { | ||
const token = getMockToken({ | ||
name: "CeruleanBlue", | ||
original: { value: "#2a52BE" }, | ||
}); | ||
|
||
expect(transform(token, {}, {})).to.equal("transformedValue"); | ||
}); | ||
}); |
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