Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1416 from framer/fix/corrected-borders
Crossfade border-radius of "%" and "px" units
- Loading branch information
Showing
3 changed files
with
124 additions
and
11 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,100 @@ | ||
import { mixValues } from "../mix-values" | ||
|
||
describe("mixValues", () => { | ||
test("mixes borderRadius numbers", () => { | ||
const output = {} | ||
|
||
mixValues( | ||
output, | ||
{ borderTopLeftRadius: 10 }, | ||
{ borderTopLeftRadius: 20 }, | ||
0.5, | ||
false, | ||
false | ||
) | ||
|
||
expect(output).toEqual({ borderTopLeftRadius: 15 }) | ||
}) | ||
|
||
test("mixes borderRadius px", () => { | ||
const output = {} | ||
|
||
mixValues( | ||
output, | ||
{ borderTopLeftRadius: "10px" }, | ||
{ borderTopLeftRadius: "20px" }, | ||
0.5, | ||
false, | ||
false | ||
) | ||
|
||
expect(output).toEqual({ borderTopLeftRadius: 15 }) | ||
}) | ||
|
||
test("mixes borderRadius percentage", () => { | ||
const output = {} | ||
|
||
mixValues( | ||
output, | ||
{ borderTopLeftRadius: "10%" }, | ||
{ borderTopLeftRadius: "20%" }, | ||
0.5, | ||
false, | ||
false | ||
) | ||
|
||
expect(output).toEqual({ borderTopLeftRadius: "15%" }) | ||
}) | ||
|
||
test("mixes borderRadius percentage with 0", () => { | ||
const output = {} | ||
|
||
mixValues( | ||
output, | ||
{ borderTopLeftRadius: 0 }, | ||
{ borderTopLeftRadius: "20%" }, | ||
0.5, | ||
false, | ||
false | ||
) | ||
|
||
expect(output).toEqual({ borderTopLeftRadius: "10%" }) | ||
|
||
mixValues( | ||
output, | ||
{ borderTopLeftRadius: "20%" }, | ||
{ borderTopLeftRadius: 0 }, | ||
0.5, | ||
false, | ||
false | ||
) | ||
|
||
expect(output).toEqual({ borderTopLeftRadius: "10%" }) | ||
}) | ||
|
||
test("doesn't mix % with px", () => { | ||
const output = {} | ||
|
||
mixValues( | ||
output, | ||
{ borderTopLeftRadius: "10px" }, | ||
{ borderTopLeftRadius: "20%" }, | ||
0.5, | ||
false, | ||
false | ||
) | ||
|
||
expect(output).toEqual({ borderTopLeftRadius: "20%" }) | ||
|
||
mixValues( | ||
output, | ||
{ borderTopLeftRadius: "20%" }, | ||
{ borderTopLeftRadius: "10px" }, | ||
0.5, | ||
false, | ||
false | ||
) | ||
|
||
expect(output).toEqual({ borderTopLeftRadius: "10px" }) | ||
}) | ||
}) |
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
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