From fb39c1615605b16846e90da14bdc89155fde8c8a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 16 Nov 2023 15:28:37 +0100 Subject: [PATCH] theme: added test for component overrides Signed-off-by: Patrik Oldsberg --- packages/theme/src/v5/types.test.ts | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 packages/theme/src/v5/types.test.ts diff --git a/packages/theme/src/v5/types.test.ts b/packages/theme/src/v5/types.test.ts new file mode 100644 index 0000000000..12bd0ff2b8 --- /dev/null +++ b/packages/theme/src/v5/types.test.ts @@ -0,0 +1,47 @@ +/* + * Copyright 2023 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { palettes } from '../base'; +import { createUnifiedTheme } from '../unified'; + +declare module '@backstage/theme' { + interface OverrideComponentNameToClassKeys { + MyTestComponent: 'root' | 'header'; + } +} + +describe('OverrideComponentNameToClassKeys', () => { + it('should provide type safe component style overrides', () => { + const theme = createUnifiedTheme({ + palette: palettes.light, + components: { + MyTestComponent: { + styleOverrides: { + root: { + color: '#f00', + }, + // @ts-expect-error + invalid: { + color: '#b45', + }, + }, + }, + }, + }); + + expect(theme).toBeDefined(); + }); +});