@@ -3,61 +3,64 @@ import { mount } from '@vue/test-utils'
33import Spacer from '../../components/Spacer.vue'
44
55describe ( 'Spacer' , ( ) => {
6- describe ( 'defaults ' , ( ) => {
6+ describe ( 'vertical ' , ( ) => {
77 it ( 'renders a div with role="separator"' , ( ) => {
88 const wrapper = mount ( Spacer )
99 expect ( wrapper . html ( ) ) . toContain ( 'role="separator"' )
1010 } )
1111
12- it ( 'renders without style attribute when no height is set ' , ( ) => {
12+ it ( 'renders without inline style by default ' , ( ) => {
1313 const wrapper = mount ( Spacer )
14- expect ( wrapper . html ( ) ) . not . toContain ( 'line-height: ' )
14+ expect ( wrapper . html ( ) ) . not . toContain ( 'style= ' )
1515 } )
1616
1717 it ( 'contains zero-width joiner' , ( ) => {
1818 const wrapper = mount ( Spacer )
1919 expect ( wrapper . text ( ) ) . toContain ( '\u200D' )
2020 } )
21- } )
2221
23- describe ( 'height prop' , ( ) => {
24- it ( 'sets line-height when provided as string' , ( ) => {
25- const wrapper = mount ( Spacer , { props : { height : '32px' } } )
26- expect ( wrapper . html ( ) ) . toContain ( 'line-height: 32px' )
22+ it ( 'passes through user leading-* class' , ( ) => {
23+ const wrapper = mount ( Spacer , { attrs : { class : 'leading-8' } } )
24+ expect ( wrapper . html ( ) ) . toContain ( 'leading-8' )
2725 } )
2826
29- it ( 'accepts a number and adds px suffix' , ( ) => {
30- const wrapper = mount ( Spacer , { props : { height : 24 } } )
31- expect ( wrapper . html ( ) ) . toContain ( 'line-height: 24px' )
27+ it ( 'passes through arbitrary mso-line-height-alt class' , ( ) => {
28+ const wrapper = mount ( Spacer , {
29+ attrs : { class : 'leading-8 [mso-line-height-alt:40px]' } ,
30+ } )
31+ const html = wrapper . html ( )
32+ expect ( html ) . toContain ( 'leading-8' )
33+ expect ( html ) . toContain ( '[mso-line-height-alt:40px]' )
3234 } )
3335
34- it ( 'preserves non-numeric string values' , ( ) => {
35- const wrapper = mount ( Spacer , { props : { height : '2rem' } } )
36- expect ( wrapper . html ( ) ) . toContain ( 'line-height: 2rem' )
37- } )
38- } )
39-
40- describe ( 'msoHeight prop' , ( ) => {
41- it ( 'sets mso-line-height-alt' , ( ) => {
42- const wrapper = mount ( Spacer , { props : { height : '32px' , msoHeight : '40px' } } )
43- expect ( wrapper . html ( ) ) . toContain ( 'mso-line-height-alt: 40px' )
36+ it ( 'rewrites h-* to leading-*' , ( ) => {
37+ const wrapper = mount ( Spacer , { attrs : { class : 'h-4' } } )
38+ const html = wrapper . html ( )
39+ expect ( html ) . toContain ( 'leading-4' )
40+ expect ( html ) . not . toContain ( 'h-4' )
4441 } )
4542
46- it ( 'accepts a number and adds px suffix' , ( ) => {
47- const wrapper = mount ( Spacer , { props : { height : '32px' , msoHeight : 48 } } )
48- expect ( wrapper . html ( ) ) . toContain ( 'mso-line-height-alt: 48px' )
43+ it ( 'rewrites arbitrary h-[3px] to leading-[3px]' , ( ) => {
44+ const wrapper = mount ( Spacer , { attrs : { class : 'h-[3px]' } } )
45+ const html = wrapper . html ( )
46+ expect ( html ) . toContain ( 'leading-[3px]' )
47+ expect ( html ) . not . toContain ( 'h-[3px]' )
4948 } )
50- } )
5149
52- describe ( 'conditional rendering' , ( ) => {
53- it ( 'renders with style when height is provided' , ( ) => {
54- const wrapper = mount ( Spacer , { props : { height : '16px' } } )
55- expect ( wrapper . html ( ) ) . toContain ( 'style=' )
50+ it ( 'drops h-* when leading-* also passed' , ( ) => {
51+ const wrapper = mount ( Spacer , { attrs : { class : 'h-4 leading-none' } } )
52+ const html = wrapper . html ( )
53+ expect ( html ) . toContain ( 'leading-none' )
54+ expect ( html ) . not . toContain ( 'h-4' )
55+ expect ( html ) . not . toContain ( 'leading-4' )
5656 } )
5757
58- it ( 'renders without style when no height is provided' , ( ) => {
59- const wrapper = mount ( Spacer )
60- expect ( wrapper . html ( ) ) . not . toContain ( 'style=' )
58+ it ( 'preserves other classes alongside h-* rewrite' , ( ) => {
59+ const wrapper = mount ( Spacer , { attrs : { class : 'h-4 my-2' } } )
60+ const html = wrapper . html ( )
61+ expect ( html ) . toContain ( 'my-2' )
62+ expect ( html ) . toContain ( 'leading-4' )
63+ expect ( html ) . not . toContain ( 'h-4' )
6164 } )
6265 } )
6366
@@ -126,14 +129,6 @@ describe('Spacer', () => {
126129 } )
127130
128131 describe ( 'outlookFallback=false' , ( ) => {
129- it ( 'omits mso-line-height-alt on vertical' , ( ) => {
130- const html = mount ( Spacer , {
131- props : { outlookFallback : false , height : 32 , msoHeight : 24 } ,
132- } ) . html ( )
133- expect ( html ) . toContain ( 'line-height: 32px' )
134- expect ( html ) . not . toContain ( 'mso-line-height-alt' )
135- } )
136-
137132 it ( 'omits mso-font-width on horizontal' , ( ) => {
138133 const html = mount ( Spacer , {
139134 props : { outlookFallback : false , type : 'horizontal' , width : 32 } ,
0 commit comments