@@ -29,150 +29,6 @@ describe('theming api', () => {
2929 } ) ;
3030 } ) ;
3131
32- it ( 'should warn if color styles are duplicated' , ( ) => {
33- spyOn ( process . stderr , 'write' ) ;
34-
35- transpile ( `
36- $theme: mat.m2-define-light-theme((
37- color: (
38- primary: mat.m2-define-palette(mat.$m2-red-palette),
39- accent: mat.m2-define-palette(mat.$m2-red-palette),
40- )
41- ));
42-
43- @include mat.all-component-themes($theme);
44-
45- .dark-theme {
46- @include mat.all-component-themes($theme);
47- }
48- ` ) ;
49-
50- expectWarning ( / T h e s a m e c o l o r s t y l e s a r e g e n e r a t e d m u l t i p l e t i m e s / ) ;
51- } ) ;
52-
53- it ( 'should not warn if color styles and density are not duplicated' , ( ) => {
54- const parsed = parse (
55- transpile ( `
56- $theme: mat.m2-define-light-theme((
57- color: (
58- primary: mat.m2-define-palette(mat.$m2-red-palette),
59- accent: mat.m2-define-palette(mat.$m2-red-palette),
60- )
61- ));
62- $theme2: mat.m2-define-light-theme((
63- color: (
64- primary: mat.m2-define-palette(mat.$m2-red-palette),
65- accent: mat.m2-define-palette(mat.$m2-blue-palette),
66- )
67- ));
68-
69- @include mat.all-component-themes($theme);
70-
71- .dark-theme {
72- @include mat.all-component-colors($theme2);
73- }
74- ` ) ,
75- ) ;
76-
77- expect ( hasDensityStyles ( parsed , null ) ) . toBe ( 'all' ) ;
78- expect ( hasDensityStyles ( parsed , '.dark-theme' ) ) . toBe ( 'none' ) ;
79- expectNoWarning ( / T h e s a m e c o l o r s t y l e s a r e g e n e r a t e d m u l t i p l e t i m e s / ) ;
80- } ) ;
81-
82- it ( 'should warn if default density styles are duplicated' , ( ) => {
83- spyOn ( process . stderr , 'write' ) ;
84-
85- const parsed = parse (
86- transpile ( `
87- @include mat.all-component-themes((color: null));
88-
89- .dark-theme {
90- @include mat.all-component-themes((color: null));
91- }
92- ` ) ,
93- ) ;
94-
95- expect ( hasDensityStyles ( parsed , null ) ) . toBe ( 'all' ) ;
96- // TODO(mmalerba): Re-enable - disabled because this test does not account
97- // for the fact that:
98- // ```scss
99- // @include mat.button-theme($theme);
100- // @include mat.checkbox-theme($theme);
101- // ```
102- // produces different results than:
103- // ```scss
104- // html {
105- // @include mat.button-theme($theme);
106- // @include mat.checkbox-theme($theme);
107- // }
108- // ```
109- // expect(hasDensityStyles(parsed, '.dark-theme')).toBe('all');
110- expectWarning ( / T h e s a m e d e n s i t y s t y l e s a r e g e n e r a t e d m u l t i p l e t i m e s / ) ;
111- } ) ;
112-
113- it ( 'should warn if density styles are duplicated' , ( ) => {
114- spyOn ( process . stderr , 'write' ) ;
115-
116- transpile ( `
117- @include mat.all-component-themes((density: -1));
118-
119- .dark-theme {
120- @include mat.all-component-themes((density: -1));
121- }
122- ` ) ;
123-
124- expectWarning ( / T h e s a m e d e n s i t y s t y l e s a r e g e n e r a t e d m u l t i p l e t i m e s / ) ;
125- } ) ;
126-
127- it ( 'should not warn if density styles are not duplicated' , ( ) => {
128- spyOn ( process . stderr , 'write' ) ;
129-
130- transpile ( `
131- @include mat.all-component-themes((density: -1));
132-
133- .dark-theme {
134- @include mat.all-component-themes((density: -2));
135- }
136- ` ) ;
137-
138- expect ( process . stderr . write ) . toHaveBeenCalledTimes ( 0 ) ;
139- } ) ;
140-
141- it ( 'should warn if typography styles are duplicated' , ( ) => {
142- spyOn ( process . stderr , 'write' ) ;
143-
144- transpile ( `
145- $theme: (typography: mat.m2-define-typography-config(), density: null);
146- @include mat.all-component-themes($theme);
147-
148- .dark-theme {
149- @include mat.all-component-themes($theme);
150- }
151- ` ) ;
152-
153- expectWarning ( / T h e s a m e t y p o g r a p h y s t y l e s a r e g e n e r a t e d m u l t i p l e t i m e s / ) ;
154- } ) ;
155-
156- it ( 'should not warn if typography styles are not duplicated' , ( ) => {
157- spyOn ( process . stderr , 'write' ) ;
158-
159- transpile ( `
160- @include mat.all-component-themes((
161- typography: mat.m2-define-typography-config(),
162- density: null,
163- ));
164-
165- .dark-theme {
166- @include mat.all-component-themes((
167- typography: mat.m2-define-typography-config($font-family: "sans-serif"),
168- density: null,
169- ));
170- }
171- ` ) ;
172-
173- expect ( process . stderr . write ) . toHaveBeenCalledTimes ( 0 ) ;
174- } ) ;
175-
17632 /**
17733 * Checks whether the given parsed stylesheet contains density styles scoped to
17834 * a given selector. If the selector is `null`, then density is expected to be
0 commit comments