From 26235158fa9cd09d23b3f792e4d0da7d69b28711 Mon Sep 17 00:00:00 2001 From: Yen Colon Date: Fri, 15 Jan 2021 10:25:28 -0400 Subject: [PATCH] reactions cells --- .../PartReactionsCell/PartReactionsCell.js | 22 ++++++++++++++++ .../PartReactionsCell.mock.js | 6 +++++ .../PartReactionsCell.stories.js | 20 ++++++++++++++ .../PartReactionsCell.test.js | 26 +++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 web/src/components/PartReactionsCell/PartReactionsCell.js create mode 100644 web/src/components/PartReactionsCell/PartReactionsCell.mock.js create mode 100644 web/src/components/PartReactionsCell/PartReactionsCell.stories.js create mode 100644 web/src/components/PartReactionsCell/PartReactionsCell.test.js diff --git a/web/src/components/PartReactionsCell/PartReactionsCell.js b/web/src/components/PartReactionsCell/PartReactionsCell.js new file mode 100644 index 0000000..1d311e2 --- /dev/null +++ b/web/src/components/PartReactionsCell/PartReactionsCell.js @@ -0,0 +1,22 @@ +export const QUERY = gql` + query PartReactionsQuery { + partReactions { + id + emote + user { + id + name + } + } + } +` + +export const Loading = () =>
Loading...
+ +export const Empty = () =>
Empty
+ +export const Failure = ({ error }) =>
Error: {error.message}
+ +export const Success = ({ partReactions }) => { + return JSON.stringify(partReactions) +} diff --git a/web/src/components/PartReactionsCell/PartReactionsCell.mock.js b/web/src/components/PartReactionsCell/PartReactionsCell.mock.js new file mode 100644 index 0000000..d96dad4 --- /dev/null +++ b/web/src/components/PartReactionsCell/PartReactionsCell.mock.js @@ -0,0 +1,6 @@ +// Define your own mock data here: +export const standard = (/* vars, { ctx, req } */) => ({ + partReactions: { + id: 42, + }, +}) diff --git a/web/src/components/PartReactionsCell/PartReactionsCell.stories.js b/web/src/components/PartReactionsCell/PartReactionsCell.stories.js new file mode 100644 index 0000000..dfd7507 --- /dev/null +++ b/web/src/components/PartReactionsCell/PartReactionsCell.stories.js @@ -0,0 +1,20 @@ +import { Loading, Empty, Failure, Success } from './PartReactionsCell' +import { standard } from './PartReactionsCell.mock' + +export const loading = () => { + return Loading ? : null +} + +export const empty = () => { + return Empty ? : null +} + +export const failure = () => { + return Failure ? : null +} + +export const success = () => { + return Success ? : null +} + +export default { title: 'Cells/PartReactionsCell' } diff --git a/web/src/components/PartReactionsCell/PartReactionsCell.test.js b/web/src/components/PartReactionsCell/PartReactionsCell.test.js new file mode 100644 index 0000000..0b9b0d1 --- /dev/null +++ b/web/src/components/PartReactionsCell/PartReactionsCell.test.js @@ -0,0 +1,26 @@ +import { render, screen } from '@redwoodjs/testing' +import { Loading, Empty, Failure, Success } from './PartReactionsCell' +import { standard } from './PartReactionsCell.mock' + +describe('PartReactionsCell', () => { + test('Loading renders successfully', () => { + render() + // Use screen.debug() to see output + expect(screen.getByText('Loading...')).toBeInTheDocument() + }) + + test('Empty renders successfully', async () => { + render() + expect(screen.getByText('Empty')).toBeInTheDocument() + }) + + test('Failure renders successfully', async () => { + render() + expect(screen.getByText(/Oh no/i)).toBeInTheDocument() + }) + + test('Success renders successfully', async () => { + render() + expect(screen.getByText(/42/i)).toBeInTheDocument() + }) +})