Skip to content

Commit

Permalink
Remove wrapping describe calls in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Jan 15, 2024
1 parent 441f0d0 commit d02df0c
Show file tree
Hide file tree
Showing 74 changed files with 776 additions and 879 deletions.
6 changes: 2 additions & 4 deletions packages/fuselage-toastbar/src/ToastBar.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import * as stories from './stories';

const { ToastBarWithData } = composeStories(stories);

describe('[ToastBarWithData Component]', () => {
it('renders without crashing', () => {
render(<ToastBarWithData />);
});
it('renders without crashing', () => {
render(<ToastBarWithData />);
});
16 changes: 7 additions & 9 deletions packages/fuselage/src/components/Accordion/Accordion.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import * as stories from './Accordion.stories';

const { Default } = composeStories(stories);

describe('[Accordion Component]', () => {
it('renders without crashing', () => {
render(<Default />);
});
it('renders without crashing', () => {
render(<Default />);
});

it('should have no a11y violations', async () => {
const { container } = render(<Default />);
it('should have no a11y violations', async () => {
const { container } = render(<Default />);

const results = await axe(container);
expect(results).toHaveNoViolations();
});
const results = await axe(container);
expect(results).toHaveNoViolations();
});
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ const AnimatedVisibility = (props: AnimatedVisibilityProps) => {

const className = useStyle(
css`
animation-duration: 230ms;
${process.env.NODE_ENV !== 'test'
? css`
animation-duration: 230ms;
`
: ''}
${visibility === Visibility.HIDING &&
css`
Expand Down
32 changes: 15 additions & 17 deletions packages/fuselage/src/components/AutoComplete/AutoComplete.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,20 @@ const testCases = Object.values(composeStories(stories)).map((Story) => [

withResizeObserverMock();

describe('[AutoComplete Rendering]', () => {
test.each(testCases)(
`renders %s without crashing`,
async (_storyname, Story) => {
const tree = render(<Story />);
expect(tree.baseElement).toMatchSnapshot();
}
);
test.each(testCases)(
`renders %s without crashing`,
async (_storyname, Story) => {
const tree = render(<Story />);
expect(tree.baseElement).toMatchSnapshot();
}
);

test.each(testCases)(
'%s should have no a11y violations',
async (_storyname, Story) => {
const { container } = render(<Story />);
test.each(testCases)(
'%s should have no a11y violations',
async (_storyname, Story) => {
const { container } = render(<Story />);

const results = await axe(container);
expect(results).toHaveNoViolations();
}
);
});
const results = await axe(container);
expect(results).toHaveNoViolations();
}
);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`[AutoComplete Rendering] renders CustomItem without crashing 1`] = `
exports[`renders CustomItem without crashing 1`] = `
<body>
<div>
<div
Expand Down Expand Up @@ -31,7 +31,7 @@ exports[`[AutoComplete Rendering] renders CustomItem without crashing 1`] = `
</body>
`;

exports[`[AutoComplete Rendering] renders CustomSelected without crashing 1`] = `
exports[`renders CustomSelected without crashing 1`] = `
<body>
<div>
<div
Expand Down Expand Up @@ -129,7 +129,7 @@ v/L21v8BT/ZVoe1UItsAAAAASUVORK5CYII="
</body>
`;

exports[`[AutoComplete Rendering] renders Default without crashing 1`] = `
exports[`renders Default without crashing 1`] = `
<body>
<div>
<div
Expand Down Expand Up @@ -160,7 +160,7 @@ exports[`[AutoComplete Rendering] renders Default without crashing 1`] = `
</body>
`;

exports[`[AutoComplete Rendering] renders Multiple without crashing 1`] = `
exports[`renders Multiple without crashing 1`] = `
<body>
<div>
<div
Expand Down Expand Up @@ -227,7 +227,7 @@ exports[`[AutoComplete Rendering] renders Multiple without crashing 1`] = `
</body>
`;

exports[`[AutoComplete Rendering] renders MultipleCustomSelected without crashing 1`] = `
exports[`renders MultipleCustomSelected without crashing 1`] = `
<body>
<div>
<div
Expand Down
32 changes: 15 additions & 17 deletions packages/fuselage/src/components/Avatar/Avatar.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,20 @@ const testCases = Object.values(composeStories(stories)).map((Story) => [
Story,
]);

describe('[Avatar Component]', () => {
test.each(testCases)(
`renders %s without crashing`,
async (_storyname, Story) => {
const tree = render(<Story />);
expect(tree.baseElement).toMatchSnapshot();
}
);
test.each(testCases)(
`renders %s without crashing`,
async (_storyname, Story) => {
const tree = render(<Story />);
expect(tree.baseElement).toMatchSnapshot();
}
);

test.each(testCases)(
'%s should have no a11y violations',
async (_storyname, Story) => {
const { container } = render(<Story />);
test.each(testCases)(
'%s should have no a11y violations',
async (_storyname, Story) => {
const { container } = render(<Story />);

const results = await axe(container);
expect(results).toHaveNoViolations();
}
);
});
const results = await axe(container);
expect(results).toHaveNoViolations();
}
);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`[Avatar Component] renders Default without crashing 1`] = `
exports[`renders Default without crashing 1`] = `
<body>
<div>
<div
Expand Down Expand Up @@ -124,7 +124,7 @@ exports[`[Avatar Component] renders Default without crashing 1`] = `
</body>
`;

exports[`[Avatar Component] renders Rounded without crashing 1`] = `
exports[`renders Rounded without crashing 1`] = `
<body>
<div>
<div
Expand Down Expand Up @@ -248,7 +248,7 @@ exports[`[Avatar Component] renders Rounded without crashing 1`] = `
</body>
`;

exports[`[Avatar Component] renders Stack without crashing 1`] = `
exports[`renders Stack without crashing 1`] = `
<body>
<div>
<div
Expand Down Expand Up @@ -570,7 +570,7 @@ exports[`[Avatar Component] renders Stack without crashing 1`] = `
</body>
`;

exports[`[Avatar Component] renders StackRounded without crashing 1`] = `
exports[`renders StackRounded without crashing 1`] = `
<body>
<div>
<div
Expand Down
80 changes: 39 additions & 41 deletions packages/fuselage/src/components/Badge/Badge.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,49 @@ import * as stories from './Badge.stories';
const { Default, Primary, Secondary, Danger, Warning, Disabled } =
composeStories(stories);

describe('[Badge Component]', () => {
describe('Story renders without crashing', () => {
it('Default', () => {
render(<Default />);
});
it('Primary', () => {
render(<Primary />);
});
it('Secondary', () => {
render(<Secondary />);
});
it('Danger', () => {
render(<Danger />);
});
it('Warning', () => {
render(<Warning />);
});
it('Disabled', () => {
render(<Disabled />);
});
describe('Story renders without crashing', () => {
it('Default', () => {
render(<Default />);
});

it('should display children', () => {
render(<Badge>Children</Badge>);
screen.getByText('Children');
it('Primary', () => {
render(<Primary />);
});

it('should have class according to variant', () => {
const { container } = render(<Badge variant='primary' />);
expect(container.querySelector('.rcx-badge--primary')).toBeInTheDocument();
it('Secondary', () => {
render(<Secondary />);
});

it('should have class passed as property', () => {
const { container } = render(<Badge className='test-class' />);
expect(container.querySelector('.test-class')).toBeInTheDocument();
it('Danger', () => {
render(<Danger />);
});

it('should show title when hovered', () => {
const { container } = render(<Badge title='test-title' />);
const badgeTitle = container.querySelector('span');
expect(badgeTitle?.getAttribute('title')).toEqual('test-title');
it('Warning', () => {
render(<Warning />);
});

it('should have disabled class if it has the disabled property', () => {
const { container } = render(<Badge disabled />);
expect(container.querySelector('.rcx-badge--disabled')).toBeInTheDocument();
it('Disabled', () => {
render(<Disabled />);
});
});

it('should display children', () => {
render(<Badge>Children</Badge>);
screen.getByText('Children');
});

it('should have class according to variant', () => {
const { container } = render(<Badge variant='primary' />);
expect(container.querySelector('.rcx-badge--primary')).toBeInTheDocument();
});

it('should have class passed as property', () => {
const { container } = render(<Badge className='test-class' />);
expect(container.querySelector('.test-class')).toBeInTheDocument();
});

it('should show title when hovered', () => {
const { container } = render(<Badge title='test-title' />);
const badgeTitle = container.querySelector('span');
expect(badgeTitle?.getAttribute('title')).toEqual('test-title');
});

it('should have disabled class if it has the disabled property', () => {
const { container } = render(<Badge disabled />);
expect(container.querySelector('.rcx-badge--disabled')).toBeInTheDocument();
});
22 changes: 10 additions & 12 deletions packages/fuselage/src/components/Banner/Banner.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ import Banner from './Banner';

withResizeObserverMock();

describe('[Banner Component]', () => {
it('renders without crashing', () => {
render(<Banner />);
});
it('renders without crashing', () => {
render(<Banner />);
});

it('renders with link', () => {
render(<Banner link='https://rocket.chat' linkText='More info' />);
expect(
screen.getByRole('link', {
name: /more info/i,
})
).toBeInTheDocument();
});
it('renders with link', () => {
render(<Banner link='https://rocket.chat' linkText='More info' />);
expect(
screen.getByRole('link', {
name: /more info/i,
})
).toBeInTheDocument();
});
Loading

0 comments on commit d02df0c

Please sign in to comment.