-
Notifications
You must be signed in to change notification settings - Fork 802
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JS Components: Convert JetpackFooter component to TypeScript (#25295)
* [not verified] Convert JetpackFooter component to TypeScript * [not verified] Convert JetpackFooter stories to TypeScript * [not verified] Convert JetpackFooter tests to TypeScript * [not verified] Add more test cases * [not verified] Fix story source not loading * Add changelog * E2E tests expect React to be in scope 🤷 * Fix version * Add default controls for story
- Loading branch information
1 parent
890539b
commit bf00452
Showing
7 changed files
with
99 additions
and
57 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
projects/js-packages/components/changelog/update-rna-jetpack-footer-to-ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: changed | ||
|
||
JS Components: Convert JetpackFooter component to TypeScript |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
projects/js-packages/components/components/jetpack-footer/stories/index.jsx
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
projects/js-packages/components/components/jetpack-footer/stories/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import JetpackFooter from '../index'; | ||
import type { ComponentStory, ComponentMeta } from '@storybook/react'; | ||
|
||
export default { | ||
title: 'JS Packages/Components/Jetpack Footer', | ||
component: JetpackFooter, | ||
} as ComponentMeta< typeof JetpackFooter >; | ||
|
||
const Template: ComponentStory< typeof JetpackFooter > = args => <JetpackFooter { ...args } />; | ||
|
||
const DefaultArgs = { | ||
a8cLogoHref: 'https://automattic.com', | ||
moduleName: 'Jetpack', | ||
className: '', | ||
moduleNameHref: 'https://jetpack.com', | ||
}; | ||
|
||
export const _default = Template.bind( {} ); | ||
_default.args = DefaultArgs; |
17 changes: 0 additions & 17 deletions
17
projects/js-packages/components/components/jetpack-footer/test/component.jsx
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
projects/js-packages/components/components/jetpack-footer/test/component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import JetpackFooter from '../index'; | ||
|
||
describe( 'JetpackFooter', () => { | ||
const testProps = { | ||
className: 'sample-classname', | ||
}; | ||
|
||
describe( 'Render the JetpackFooter component', () => { | ||
it( 'validate the class name', () => { | ||
const { container } = render( <JetpackFooter { ...testProps } /> ); | ||
// eslint-disable-next-line testing-library/no-node-access | ||
expect( container.firstChild ).toHaveClass( 'sample-classname' ); | ||
} ); | ||
|
||
it( 'validates Jetpack logo', () => { | ||
render( <JetpackFooter /> ); | ||
|
||
expect( screen.getByLabelText( 'Jetpack logo' ) ).toBeInTheDocument(); | ||
} ); | ||
|
||
it( 'tests for module name and link', () => { | ||
render( | ||
<JetpackFooter | ||
moduleName="Test module" | ||
moduleNameHref="https://jetpack.com/path/to-some-page" | ||
/> | ||
); | ||
|
||
const element = screen.getByLabelText( 'Test module' ); | ||
|
||
expect( element ).toBeInTheDocument(); | ||
expect( element ).toBeInstanceOf( HTMLAnchorElement ); | ||
expect( element ).toHaveAttribute( 'href', 'https://jetpack.com/path/to-some-page' ); | ||
} ); | ||
|
||
it( 'validates the a8c label', () => { | ||
render( <JetpackFooter /> ); | ||
|
||
for ( const element of screen.getAllByLabelText( 'An Automattic Airline' ) ) { | ||
expect( element ).toBeInTheDocument(); | ||
} | ||
} ); | ||
} ); | ||
} ); |
21 changes: 21 additions & 0 deletions
21
projects/js-packages/components/components/jetpack-footer/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export type JetpackFooterProps = { | ||
/** | ||
* Link for 'An Automattic Airline'. | ||
*/ | ||
a8cLogoHref?: string; | ||
|
||
/** | ||
* Name of the module, e.g. 'Jetpack Search'. | ||
*/ | ||
moduleName?: string; | ||
|
||
/** | ||
* additional className of the wrapper, `jp-dashboard-footer` always included. | ||
*/ | ||
className?: string; | ||
|
||
/** | ||
* Link that the Module name will link to (optional). | ||
*/ | ||
moduleNameHref?: string; | ||
}; |