@@ -22,7 +22,8 @@ import {
2222 opacify ,
2323 transparentize ,
2424 flex ,
25- grid
25+ grid ,
26+ position
2627} from "./styled-tidy" ;
2728
2829declare interface TestProps {
@@ -334,4 +335,62 @@ describe("styed-tidy", () => {
334335 expect ( getByText ( "test" ) ) . toHaveStyleRule ( "grid-row-gap" , "1rem" ) ;
335336 } ) ;
336337 } ) ;
338+
339+ describe ( "'position' mixin" , ( ) => {
340+ it ( "sets the given position CSS attributes" , ( ) => {
341+ const Test = styled . div < TestProps > `
342+ ${ position ( "fixed" , "1rem" , "2rem" , "3rem" , "4rem" ) } ;
343+ ` ;
344+ const { getByText } = setup ( < Test > test</ Test > ) ;
345+ const test = getByText ( "test" ) ;
346+
347+ expect ( test ) . toHaveStyleRule ( "position" , "fixed" ) ;
348+ expect ( test ) . toHaveStyleRule ( "top" , "1rem" ) ;
349+ expect ( test ) . toHaveStyleRule ( "right" , "2rem" ) ;
350+ expect ( test ) . toHaveStyleRule ( "bottom" , "3rem" ) ;
351+ expect ( test ) . toHaveStyleRule ( "left" , "4rem" ) ;
352+ } ) ;
353+
354+ it ( "sets the given position CSS attributes with single param shorthand" , ( ) => {
355+ const Test = styled . div < TestProps > `
356+ ${ position ( "absolute" , "1rem" ) } ;
357+ ` ;
358+ const { getByText } = setup ( < Test > test</ Test > ) ;
359+ const test = getByText ( "test" ) ;
360+
361+ expect ( test ) . toHaveStyleRule ( "position" , "absolute" ) ;
362+ expect ( test ) . toHaveStyleRule ( "top" , "1rem" ) ;
363+ expect ( test ) . toHaveStyleRule ( "right" , "1rem" ) ;
364+ expect ( test ) . toHaveStyleRule ( "bottom" , "1rem" ) ;
365+ expect ( test ) . toHaveStyleRule ( "left" , "1rem" ) ;
366+ } ) ;
367+
368+ it ( "sets the given position CSS attributes with double param shorthand" , ( ) => {
369+ const Test = styled . div < TestProps > `
370+ ${ position ( "absolute" , "1rem" , "2rem" ) } ;
371+ ` ;
372+ const { getByText } = setup ( < Test > test</ Test > ) ;
373+ const test = getByText ( "test" ) ;
374+
375+ expect ( test ) . toHaveStyleRule ( "position" , "absolute" ) ;
376+ expect ( test ) . toHaveStyleRule ( "top" , "1rem" ) ;
377+ expect ( test ) . toHaveStyleRule ( "right" , "2rem" ) ;
378+ expect ( test ) . toHaveStyleRule ( "bottom" , "1rem" ) ;
379+ expect ( test ) . toHaveStyleRule ( "left" , "2rem" ) ;
380+ } ) ;
381+
382+ it ( "sets the given position CSS attributes with triple param shorthand" , ( ) => {
383+ const Test = styled . div < TestProps > `
384+ ${ position ( "absolute" , "1rem" , "2rem" , "3rem" ) } ;
385+ ` ;
386+ const { getByText } = setup ( < Test > test</ Test > ) ;
387+ const test = getByText ( "test" ) ;
388+
389+ expect ( test ) . toHaveStyleRule ( "position" , "absolute" ) ;
390+ expect ( test ) . toHaveStyleRule ( "top" , "1rem" ) ;
391+ expect ( test ) . toHaveStyleRule ( "right" , "2rem" ) ;
392+ expect ( test ) . toHaveStyleRule ( "bottom" , "3rem" ) ;
393+ expect ( test ) . toHaveStyleRule ( "left" , "2rem" ) ;
394+ } ) ;
395+ } ) ;
337396} ) ;
0 commit comments