-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b30ce66
commit f95fdd4
Showing
19 changed files
with
403 additions
and
87 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
.cardGrid { | ||
display: grid; | ||
grid-gap: 24px 16px; | ||
.cell { | ||
padding: 8px; | ||
} |
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 |
---|---|---|
@@ -1,12 +1,17 @@ | ||
import * as React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import { generatePlaylistPlaceholder } from '../../utils/collection'; | ||
|
||
import CardGrid from './CardGrid'; | ||
|
||
describe('<CardGrid>', () => { | ||
it('renders card grid and children', () => { | ||
const { getByText } = render(<CardGrid>aa</CardGrid>); | ||
const cardGrid = getByText(/aa/i); | ||
expect(document.body.contains(cardGrid)); | ||
it('renders and matches snapshot', () => { | ||
const placeholderData = generatePlaylistPlaceholder(); | ||
const { container } = render(( | ||
<CardGrid playlist={placeholderData.playlist} onCardHover={jest.fn()} onCardClick={jest.fn()} isLoading={false} /> | ||
)); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
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
32 changes: 32 additions & 0 deletions
32
src/components/CardGrid/__snapshots__/CardGrid.test.tsx.snap
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,32 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<CardGrid> renders and matches snapshot 1`] = ` | ||
<div> | ||
<div | ||
style="overflow: visible; width: 0px;" | ||
> | ||
<div | ||
aria-label="grid" | ||
aria-readonly="true" | ||
class="ReactVirtualized__Grid grid" | ||
role="grid" | ||
style="box-sizing: border-box; direction: ltr; height: auto; position: relative; width: 0px; will-change: transform; overflow-x: hidden; overflow-y: hidden;" | ||
tabindex="-1" | ||
/> | ||
</div> | ||
<div | ||
class="resize-triggers" | ||
> | ||
<div | ||
class="expand-trigger" | ||
> | ||
<div | ||
style="width: 1px; height: 1px;" | ||
/> | ||
</div> | ||
<div | ||
class="contract-trigger" | ||
/> | ||
</div> | ||
</div> | ||
`; |
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,39 @@ | ||
@use '../../styles/variables'; | ||
@use '../../styles/theme'; | ||
@use '../../styles/mixins/responsive'; | ||
|
||
.errorPage { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
height: 70vh; | ||
} | ||
|
||
.box { | ||
max-width: 500px; | ||
padding: 12px; | ||
font-family: theme.$body-font-family; | ||
} | ||
|
||
.title { | ||
margin-bottom: 24px; | ||
font-size: 34px; | ||
font-weight: 700; | ||
color: variables.$white; | ||
} | ||
|
||
.main { | ||
color: variables.$white; | ||
|
||
> h6 { | ||
margin-bottom: 16px; | ||
font-weight: 700; | ||
font-size: 20px; | ||
} | ||
} | ||
|
||
@include responsive.mobile-only() { | ||
.title { | ||
font-size: 24px; | ||
} | ||
} |
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,12 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import ErrorPage from './ErrorPage'; | ||
|
||
describe('<ErrorPage>', () => { | ||
test('renders and matches snapshot', () => { | ||
const { container } = render(<ErrorPage title="This is the title">This is the content</ErrorPage>); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
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,25 @@ | ||
import React from 'react'; | ||
|
||
import styles from './ErrorPage.module.scss'; | ||
|
||
type Props = { | ||
title: string; | ||
children?: React.ReactNode; | ||
}; | ||
|
||
const ErrorPage: React.FC<Props> = ({ title, children }: Props) => { | ||
return ( | ||
<div className={styles.errorPage}> | ||
<div className={styles.box}> | ||
<header> | ||
<h1 className={styles.title}>{title}</h1> | ||
</header> | ||
<main className={styles.main}> | ||
{children} | ||
</main> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ErrorPage; |
26 changes: 26 additions & 0 deletions
26
src/components/ErrorPage/__snapshots__/ErrorPage.test.tsx.snap
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,26 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<ErrorPage> renders and matches snapshot 1`] = ` | ||
<div> | ||
<div | ||
class="errorPage" | ||
> | ||
<div | ||
class="box" | ||
> | ||
<header> | ||
<h1 | ||
class="title" | ||
> | ||
This is the title | ||
</h1> | ||
</header> | ||
<main | ||
class="main" | ||
> | ||
This is the content | ||
</main> | ||
</div> | ||
</div> | ||
</div> | ||
`; |
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
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
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
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
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
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,13 @@ | ||
import { useEffect, useRef } from 'react'; | ||
|
||
const useFirstRender = () => { | ||
const firstRenderRef = useRef(true); | ||
|
||
useEffect(() => { | ||
firstRenderRef.current = false; | ||
}, []); | ||
|
||
return firstRenderRef.current; | ||
}; | ||
|
||
export default useFirstRender; |
Oops, something went wrong.