File tree Expand file tree Collapse file tree 2 files changed +49
-4
lines changed Expand file tree Collapse file tree 2 files changed +49
-4
lines changed Original file line number Diff line number Diff line change @@ -102,10 +102,10 @@ export function spacing(
102102 "bottom" : topBottom
103103 } ;
104104 } ) ( ) ,
105- "top" : params . top ,
106- "right" : params . right ,
107- "bottom" : params . bottom ,
108- "left" : params . left
105+ ... ( params . top === undefined ? undefined : { "top" : params . top } ) ,
106+ ... ( params . right === undefined ? undefined : { "right" : params . right } ) ,
107+ ... ( params . bottom === undefined ? undefined : { "bottom" : params . bottom } ) ,
108+ ... ( params . left === undefined ? undefined : { "left" : params . left } )
109109 } ;
110110
111111 ( [ "top" , "right" , "bottom" , "left" ] as const ) . forEach ( p => {
Original file line number Diff line number Diff line change @@ -9,4 +9,49 @@ describe("Testing the replacer function", () => {
99
1010 expect ( got ) . toBe ( expected ) ;
1111 } ) ;
12+
13+ it ( "Works with margin topBottom" , ( ) => {
14+ const got = spacing ( "margin" , { "topBottom" : "13w" } ) ;
15+
16+ const expected = {
17+ "marginTop" : "6.5rem" ,
18+ "marginBottom" : "6.5rem"
19+ } ;
20+
21+ expect ( got ) . toStrictEqual ( expected ) ;
22+ } ) ;
23+
24+ it ( "Works with margin topBottom and left" , ( ) => {
25+ const got = spacing ( "margin" , { "topBottom" : "13w" , "left" : 3 } ) ;
26+
27+ const expected = {
28+ "marginTop" : "6.5rem" ,
29+ "marginBottom" : "6.5rem" ,
30+ "marginLeft" : 3
31+ } ;
32+
33+ expect ( got ) . toStrictEqual ( expected ) ;
34+ } ) ;
35+
36+ it ( "Works with margin topBottom overwriting bottom" , ( ) => {
37+ const got = spacing ( "margin" , { "topBottom" : "13w" , "bottom" : 3 } ) ;
38+
39+ const expected = {
40+ "marginTop" : "6.5rem" ,
41+ "marginBottom" : 3
42+ } ;
43+
44+ expect ( got ) . toStrictEqual ( expected ) ;
45+ } ) ;
46+
47+ it ( "Works with padding and rightLeft" , ( ) => {
48+ const got = spacing ( "padding" , { "rightLeft" : "1v" } ) ;
49+
50+ const expected = {
51+ "paddingRight" : "0.25rem" ,
52+ "paddingLeft" : "0.25rem"
53+ } ;
54+
55+ expect ( got ) . toStrictEqual ( expected ) ;
56+ } ) ;
1257} ) ;
You can’t perform that action at this time.
0 commit comments