From dfd0b8d16b886b0e077c8eb658f53bab766537ba Mon Sep 17 00:00:00 2001 From: Gaurav Pandey <36168816+grvpandey11@users.noreply.github.com> Date: Sun, 9 Jul 2023 02:49:14 +0200 Subject: [PATCH] Update WelcomeTitle.test.tsx Signed-off-by: Gaurav Pandey <36168816+grvpandey11@users.noreply.github.com> --- .../WelcomeTitle/WelcomeTitle.test.tsx | 50 +++++++++---------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/plugins/home/src/homePageComponents/WelcomeTitle/WelcomeTitle.test.tsx b/plugins/home/src/homePageComponents/WelcomeTitle/WelcomeTitle.test.tsx index d4c39e2a29..6d14aa7a95 100644 --- a/plugins/home/src/homePageComponents/WelcomeTitle/WelcomeTitle.test.tsx +++ b/plugins/home/src/homePageComponents/WelcomeTitle/WelcomeTitle.test.tsx @@ -1,5 +1,5 @@ /* - * Copyright 2021 The Backstage Authors + * 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. @@ -13,33 +13,29 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { renderInTestApp } from '@backstage/test-utils'; -import React from 'react'; + +import { Header } from '@backstage/core-components'; +import { wrapInTestApp } from '@backstage/test-utils'; +import React, { ComponentType, PropsWithChildren } from 'react'; import { WelcomeTitle } from './WelcomeTitle'; -describe('', () => { - afterEach(() => jest.resetAllMocks()); +export default { + title: 'Plugins/Home/Components/WelcomeTitle', + decorators: [ + (Story: ComponentType>) => wrapInTestApp(), + ], +}; - test('should greet user with default greeting', async () => { - jest - .spyOn(global.Date, 'now') - .mockImplementation(() => new Date('1970-01-01T23:00:00').valueOf()); +export const Default = () => { + return
} pageTitleOverride="Home" />; +}; - const { getByText } = await renderInTestApp(); - - expect(getByText(/Get some rest, Guest/)).toBeInTheDocument(); - }); - - test('should greet user with multiple languages', async () => { - jest - .spyOn(global.Date, 'now') - .mockImplementation(() => new Date('2023-07-03T14:00:00').valueOf()); - - const languages = ['English', 'Spanish']; - const { getByText } = await renderInTestApp( - , - ); - - expect(getByText(/Good afternoon, Guest/)).toBeInTheDocument(); - }); -}); +export const withLanguage = () => { + const languages = ['English', 'Spanish']; + return ( +
} + pageTitleOverride="Home" + /> + ); +};