@@ -126,10 +126,10 @@ describe('theming inspection api', () => {
126126 transpile ( `
127127 $theme: ${ defineM2Theme ( ) } ;
128128 div {
129- content: mat.private-get-theme-version($theme);
129+ --theme-version: #{ mat.private-get-theme-version($theme)} ;
130130 }
131131 ` ) ,
132- ) . toMatch ( / c o n t e n t : 0 ; / ) ;
132+ ) . toMatch ( '--theme-version : 0;' ) ;
133133 } ) ;
134134 } ) ;
135135
@@ -139,40 +139,40 @@ describe('theming inspection api', () => {
139139 transpile ( `
140140 $theme: ${ defineM3Theme ( ) } ;
141141 div {
142- content: mat.private-get-theme-version($theme);
142+ --theme-version: #{ mat.private-get-theme-version($theme)} ;
143143 }
144144 ` ) ,
145- ) . toMatch ( / c o n t e n t : 1 ; / ) ;
145+ ) . toMatch ( '--theme-version : 1;' ) ;
146146 } ) ;
147147
148148 it ( 'should get theme type' , ( ) => {
149149 expect (
150150 transpile ( `
151151 $theme: ${ defineM3Theme ( ) } ;
152152 div {
153- content: mat.private-get-theme-type($theme);
153+ --theme-type: #{ mat.private-get-theme-type($theme)} ;
154154 }
155155 ` ) ,
156- ) . toMatch ( / c o n t e n t : l i g h t ; / ) ;
156+ ) . toMatch ( '--theme-type : light;' ) ;
157157 } ) ;
158158
159159 it ( 'should get role color' , ( ) => {
160160 expect (
161161 transpile ( `
162162 $theme: ${ defineM3Theme ( ) } ;
163163 div {
164- content : mat.private-get-theme-color($theme, primary-container);
164+ color : mat.private-get-theme-color($theme, primary-container);
165165 }
166166 ` ) ,
167- ) . toMatch ( / c o n t e n t : # e 0 e 0 f f ; / ) ;
167+ ) . toMatch ( 'color : #e0e0ff;' ) ;
168168 } ) ;
169169
170170 it ( 'should error on invalid color role' , ( ) => {
171171 expect ( ( ) =>
172172 transpile ( `
173173 $theme: ${ defineM3Theme ( ) } ;
174174 div {
175- content : mat.private-get-theme-color($theme, fake-role);
175+ color : mat.private-get-theme-color($theme, fake-role);
176176 }
177177 ` ) ,
178178 ) . toThrowError ( / V a l i d c o l o r r o l e s a r e .* G o t : f a k e - r o l e / ) ;
@@ -183,18 +183,18 @@ describe('theming inspection api', () => {
183183 transpile ( `
184184 $theme: ${ defineM3Theme ( ) } ;
185185 div {
186- content : mat.private-get-theme-color($theme, tertiary, 20);
186+ color : mat.private-get-theme-color($theme, tertiary, 20);
187187 }
188188 ` ) ,
189- ) . toMatch ( / c o n t e n t : # 3 2 3 2 0 0 ; / ) ;
189+ ) . toMatch ( 'color : #323200;' ) ;
190190 } ) ;
191191
192192 it ( 'should error on invalid color palette' , ( ) => {
193193 expect ( ( ) =>
194194 transpile ( `
195195 $theme: ${ defineM3Theme ( ) } ;
196196 div {
197- content : mat.private-get-theme-color($theme, fake-palette, 20);
197+ color : mat.private-get-theme-color($theme, fake-palette, 20);
198198 }
199199 ` ) ,
200200 ) . toThrowError ( / V a l i d p a l e t t e s a r e .* G o t : f a k e - p a l e t t e / ) ;
@@ -205,7 +205,7 @@ describe('theming inspection api', () => {
205205 transpile ( `
206206 $theme: ${ defineM3Theme ( ) } ;
207207 div {
208- content : mat.private-get-theme-color($theme, neutral, 11);
208+ color : mat.private-get-theme-color($theme, neutral, 11);
209209 }
210210 ` ) ,
211211 ) . toThrowError ( / V a l i d h u e s f o r n e u t r a l a r e .* G o t : 1 1 / ) ;
@@ -216,10 +216,52 @@ describe('theming inspection api', () => {
216216 transpile ( `
217217 $theme: ${ defineM3Theme ( ) } ;
218218 div {
219- content : mat.private-get-theme-color($theme);
219+ color : mat.private-get-theme-color($theme);
220220 }
221221 ` ) ,
222222 ) . toThrowError ( / E x p e c t e d 2 o r 3 a r g u m e n t s . G o t : 1 / ) ;
223223 } ) ;
224+
225+ it ( 'should get typography properties from theme' , ( ) => {
226+ const css = transpile ( `
227+ $theme: ${ defineM3Theme ( ) } ;
228+ div {
229+ font: mat.private-get-theme-typography($theme, headline-large);
230+ font-family: mat.private-get-theme-typography($theme, headline-large, font-family);
231+ font-size: mat.private-get-theme-typography($theme, headline-large, font-size);
232+ font-weight: mat.private-get-theme-typography($theme, headline-large, font-weight);
233+ line-height: mat.private-get-theme-typography($theme, headline-large, line-height);
234+ letter-spacing: mat.private-get-theme-typography($theme, headline-large, letter-spacing);
235+ }
236+ ` ) ;
237+ expect ( css ) . toMatch ( 'font: 400 2rem / 2.5rem Google Sans;' ) ;
238+ expect ( css ) . toMatch ( 'font-family: Google Sans;' ) ;
239+ expect ( css ) . toMatch ( 'font-size: 2rem;' ) ;
240+ expect ( css ) . toMatch ( 'font-weight: 400;' ) ;
241+ expect ( css ) . toMatch ( 'line-height: 2.5rem;' ) ;
242+ expect ( css ) . toMatch ( 'letter-spacing: 0rem;' ) ;
243+ } ) ;
244+ } ) ;
245+
246+ it ( 'should error on invalid typescale' , ( ) => {
247+ expect ( ( ) =>
248+ transpile ( `
249+ $theme: ${ defineM3Theme ( ) } ;
250+ div {
251+ font: mat.private-get-theme-typography($theme, subtitle-large);
252+ }
253+ ` ) ,
254+ ) . toThrowError ( / V a l i d t y p e s c a l e s a r e : .* G o t : s u b t i t l e - l a r g e / ) ;
255+ } ) ;
256+
257+ it ( 'should error on invalid typography property' , ( ) => {
258+ expect ( ( ) =>
259+ transpile ( `
260+ $theme: ${ defineM3Theme ( ) } ;
261+ div {
262+ font: mat.private-get-theme-typography($theme, body-small, text-transform);
263+ }
264+ ` ) ,
265+ ) . toThrowError ( / V a l i d t y p o g r a p h y p r o p e r t i e s a r e : .* G o t : t e x t - t r a n s f o r m / ) ;
224266 } ) ;
225267} ) ;
0 commit comments