Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use composestories instead of story #556

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { render, screen, userEvent } from '@testing-library/react-native';
import { composeStory } from '@storybook/react';
import Meta, { Basic } from './Actions.stories';
import { composeStories } from '@storybook/react';
import * as Actions from './Actions.stories';

const ActionsStory = composeStory(Basic, Meta);
const { Basic } = composeStories(Actions);

test('action story renders and onpress works', async () => {
jest.useFakeTimers();

const onPress = jest.fn();

render(<ActionsStory onPress={onPress} />);
render(<Basic onPress={onPress} />);

const user = userEvent.setup({});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import '@testing-library/react-native/extend-expect';
import { render, screen } from '@testing-library/react-native';
import { composeStory } from '@storybook/react';
import Meta, { Basic } from './BackgroundCsf.stories';
import { composeStories } from '@storybook/react';
import * as Backgrounds from './BackgroundCsf.stories';

const BackgroundCsfStory = composeStory(Basic, Meta);
const { Basic } = composeStories(Backgrounds);

test('Background colour is hotpink', () => {
render(<BackgroundCsfStory />);
render(<Basic />);

expect(screen.getByTestId('addon-backgrounds-container')).toHaveStyle({
backgroundColor: 'hotpink',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { render, screen } from '@testing-library/react-native';
import { composeStory } from '@storybook/react';
import Meta, { Basic } from './Array.stories';
import { composeStories } from '@storybook/react';
import * as ArrayStories from './Array.stories';

const ArrayStory = composeStory(Basic, Meta);
const { Basic } = composeStories(ArrayStories);

test('array story renders', () => {
render(<ArrayStory />);
render(<Basic />);

expect(screen.getByTestId('array-story-container')).toHaveTextContent(/abc/);
});
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { render, screen } from '@testing-library/react-native';
import { composeStory } from '@storybook/react';
import Meta, { Basic, On } from './Boolean.stories';
import { composeStories } from '@storybook/react';
import * as BooleanStories from './Boolean.stories';

const BooleanStory = composeStory(Basic, Meta);
const OnStory = composeStory(On, Meta);
const { Basic, On } = composeStories(BooleanStories);

test('boolean story renders', () => {
render(<BooleanStory />);
render(<Basic />);

screen.getByText('off');
});

test('boolean story renders on', () => {
render(<OnStory />);
render(<On />);

screen.getByText('on');
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { render, screen } from '@testing-library/react-native';
import { composeStory } from '@storybook/react';
import Meta, { ColorExample } from './Color.stories';
import { composeStories } from '@storybook/react';
import * as Color from './Color.stories';

const ColorStory = composeStory(ColorExample, Meta);
const { ColorExample } = composeStories(Color);

test('color story renders', () => {
render(<ColorStory />);
render(<ColorExample />);

expect(screen.getByTestId('color-story-container')).toHaveStyle({ backgroundColor: '#a819b9' });
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { render, screen } from '@testing-library/react-native';
import { composeStory } from '@storybook/react';
import Meta, { Basic } from './Date.stories';
import { composeStories } from '@storybook/react';
import * as DateStories from './Date.stories';

const DateStory = composeStory(Basic, Meta);
const { Basic } = composeStories(DateStories);

test('date story renders', () => {
render(<DateStory />);
render(<Basic />);

const date = new Date(1983, 1, 25);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { render, screen } from '@testing-library/react-native';
import { composeStory } from '@storybook/react';
import Meta, { Basic, Range } from './Number.stories';
import { composeStories } from '@storybook/react';
import * as NumberStories from './Number.stories';

const BasicStory = composeStory(Basic, Meta);
const RangeStory = composeStory(Range, Meta);
const { Basic, Range } = composeStories(NumberStories);

test('basic story renders', async () => {
render(<BasicStory />);
render(<Basic />);

await screen.findByText(/5 x 3 = 15/);
});

test('range story renders', async () => {
render(<RangeStory />);
render(<Range />);

await screen.findByText(/6 x 7 = 42/);
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { render, screen } from '@testing-library/react-native';
import { composeStory } from '@storybook/react';
import Meta, { Basic } from './Object.stories';
import { composeStories } from '@storybook/react';
import * as ObjectStory from './Object.stories';

const ObjectStory = composeStory(Basic, Meta);
const { Basic } = composeStories(ObjectStory);

test('object story renders', () => {
render(<ObjectStory />);
render(<Basic />);

screen.getByText('title: Blade Runner');
screen.getByText('genre: Sci Fi');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { render, screen } from '@testing-library/react-native';
import { composeStory } from '@storybook/react';
import Meta, { Basic } from './Radio.stories';
import { composeStories } from '@storybook/react';
import * as RadioStories from './Radio.stories';

const RadioStory = composeStory(Basic, Meta);
const { Basic } = composeStories(RadioStories);

test('radio story renders', () => {
render(<RadioStory />);
render(<Basic />);

screen.getByText('104.8MHz');
});
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import { screen, render } from '@testing-library/react-native';
import { composeStory } from '@storybook/react';
import Meta, { Basic, WithLabels, WithMapping } from './Select.stories';
import { composeStories } from '@storybook/react';
import * as SelectStories from './Select.stories';

const SelectStory = composeStory(Basic, Meta);
const SelectWithLabelsStory = composeStory(WithLabels, Meta);
const SelectWithMappingStory = composeStory(WithMapping, Meta);
const { Basic, WithLabels, WithMapping } = composeStories(SelectStories);

test('select story renders', () => {
render(<SelectStory />);
render(<Basic />);

screen.getByText('Selected: ⬅️');
});

test('select with labels story renders', () => {
render(<SelectWithLabelsStory />);
render(<WithLabels />);

screen.getByText('Selected: ⬆');
});

test('select with mapping story renders', () => {
render(<SelectWithMappingStory />);
render(<WithMapping />);

screen.getByText('Selected: ⬆');
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { screen, render } from '@testing-library/react-native';
import { composeStory } from '@storybook/react';
import Meta, { Basic } from './Text.stories';
import { composeStories } from '@storybook/react';
import * as TextStories from './Text.stories';

const TextStory = composeStory(Basic, Meta);
const { Basic } = composeStories(TextStories);

test('text story renders', () => {
render(<TextStory />);
render(<Basic />);

screen.getByText('Hello world!');
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { render, screen } from '@testing-library/react-native';
import { composeStory } from '@storybook/react';
import Meta, { Basic } from './TextInput.stories';
import { composeStories } from '@storybook/react';
import * as InputStories from './TextInput.stories';

const TextInputStory = composeStory(Basic, Meta);
const { Basic } = composeStories(InputStories);

test('text input story renders', () => {
render(<TextInputStory />);
render(<Basic />);

screen.getByPlaceholderText('Type something');
});