Skip to content

Commit adc0e00

Browse files
committed
refactor: lint and tests
1 parent d96a0ef commit adc0e00

File tree

4 files changed

+4
-152
lines changed

4 files changed

+4
-152
lines changed

src/material/core/theming/_theming.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
@use 'sass:meta';
55
@use 'sass:color';
66

7+
// Deprecated flag that is no longer used to control duplication warnings.
8+
// Remove in v22
9+
$theme-ignore-duplication-warnings: false;
10+
711
// Whether to enable compatibility with legacy methods for accessing theme information.
812
$theme-legacy-inspection-api-compatibility: true !default;
913

src/material/core/theming/tests/test-theming-api.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
@use '../theming';
1010
@use 'sass:map';
1111

12-
// Disable theme style duplication warnings. This test intentionally generates
13-
// the same themes multiple times.
14-
theming.$theme-ignore-duplication-warnings: true;
15-
1612
// A new way to configure themes has been introduced. This Sass file ensures that the theming
1713
// API is backwards compatible, so that the old pattern for configuring themes can be still
1814
// used. The Sass compilation of this file will fail if one of the tests/assertions fails.

src/material/core/theming/tests/test-theming-bundle.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
// with the include paths being set to the `bazel-bin` directory.
44
@use '../../../index' as mat;
55

6-
// Disable theme style duplication warnings. This test intentionally generates
7-
// the same themes multiple times.
8-
mat.$theme-ignore-duplication-warnings: true;
9-
106
// If one of these mixins or function is not available, the compilation will fail and the
117
// test will be reported as failing.
128

src/material/core/theming/tests/theming-mixin-api.spec.ts

Lines changed: 0 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -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(/The same color styles are generated multiple times/);
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(/The same color styles are generated multiple times/);
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(/The same density styles are generated multiple times/);
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(/The same density styles are generated multiple times/);
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(/The same typography styles are generated multiple times/);
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

Comments
 (0)