From 8782465459fcfc60d4ee81006c931d38af0e8820 Mon Sep 17 00:00:00 2001 From: Szymon Graczyk Date: Mon, 30 Mar 2020 22:25:49 +0200 Subject: [PATCH 1/2] Rewrite layout/Header/Waves to use TypeScript * Add simple test looking for svg node --- .../core/src/layout/Header/Waves.test.tsx | 27 +++++++++++++++++++ .../src/layout/Header/{Waves.js => Waves.tsx} | 14 +++++++--- 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 packages/core/src/layout/Header/Waves.test.tsx rename packages/core/src/layout/Header/{Waves.js => Waves.tsx} (94%) diff --git a/packages/core/src/layout/Header/Waves.test.tsx b/packages/core/src/layout/Header/Waves.test.tsx new file mode 100644 index 0000000000..940b845d00 --- /dev/null +++ b/packages/core/src/layout/Header/Waves.test.tsx @@ -0,0 +1,27 @@ +/* + * Copyright 2020 Spotify AB + * + * 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 React from 'react'; +import { render } from '@testing-library/react'; +import Waves from './Waves'; +import { pageTheme } from '../Page/PageThemeProvider'; + +describe('', () => { + it('should render svg', () => { + const rendered = render(); + rendered.getByTestId('wave-svg'); + }); +}); diff --git a/packages/core/src/layout/Header/Waves.js b/packages/core/src/layout/Header/Waves.tsx similarity index 94% rename from packages/core/src/layout/Header/Waves.js rename to packages/core/src/layout/Header/Waves.tsx index 52523834dc..c23afe69e3 100644 --- a/packages/core/src/layout/Header/Waves.js +++ b/packages/core/src/layout/Header/Waves.tsx @@ -14,10 +14,11 @@ * limitations under the License. */ -import React from 'react'; +import React, { FC } from 'react'; import { makeStyles } from '@material-ui/core'; +import { PageTheme } from '@backstage/core'; -const useStyles = makeStyles({ +const useStyles = makeStyles({ wave: { position: 'absolute', height: '100%', @@ -26,11 +27,15 @@ const useStyles = makeStyles({ bottom: 0, left: 0, right: 0, - 'z-index': -1, + zIndex: -1, }, }); -const Waves = ({ theme }) => { +type Props = { + theme: PageTheme; +}; + +const Waves: FC = ({ theme }) => { const classes = useStyles(); const [color1, color2] = theme.gradient.colors; @@ -41,6 +46,7 @@ const Waves = ({ theme }) => { fill="none" xmlns="http://www.w3.org/2000/svg" className={classes.wave} + data-testid="wave-svg" > From 39f7fe277f8888aa8305807de2ad57cc9789c0fb Mon Sep 17 00:00:00 2001 From: Szymon Graczyk Date: Mon, 30 Mar 2020 22:31:43 +0200 Subject: [PATCH 2/2] Correct the import of PageTheme to use relative path --- packages/core/src/layout/Header/Waves.test.tsx | 2 +- packages/core/src/layout/Header/Waves.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/layout/Header/Waves.test.tsx b/packages/core/src/layout/Header/Waves.test.tsx index 940b845d00..2c7d463052 100644 --- a/packages/core/src/layout/Header/Waves.test.tsx +++ b/packages/core/src/layout/Header/Waves.test.tsx @@ -16,8 +16,8 @@ import React from 'react'; import { render } from '@testing-library/react'; -import Waves from './Waves'; import { pageTheme } from '../Page/PageThemeProvider'; +import Waves from './Waves'; describe('', () => { it('should render svg', () => { diff --git a/packages/core/src/layout/Header/Waves.tsx b/packages/core/src/layout/Header/Waves.tsx index c23afe69e3..f37ecf7b12 100644 --- a/packages/core/src/layout/Header/Waves.tsx +++ b/packages/core/src/layout/Header/Waves.tsx @@ -16,7 +16,7 @@ import React, { FC } from 'react'; import { makeStyles } from '@material-ui/core'; -import { PageTheme } from '@backstage/core'; +import { PageTheme } from '../Page'; const useStyles = makeStyles({ wave: {