Skip to content

Commit

Permalink
Merge pull request #261 from I3uckwheat/hotfix/prettify-tallycount.sp…
Browse files Browse the repository at this point in the history
…ec.js

Hotfix/Prettify TallyCount.spec.js
  • Loading branch information
zachmmeyer authored Apr 24, 2021
2 parents c8ec910 + e5649ba commit ac850cb
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions frontend/src/components/TallyMarker/TallyCount.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import { render, screen } from '@testing-library/react';
import TallyCount from './TallyCount';

// https://jestjs.io/docs/en/tutorial-react#snapshot-testing-with-mocks-enzyme-and-react-16
jest.mock('./TallyGroup', () => ({ tallyCount, color }) =>
<tally-group-mock data-testid='tally-group' data-tallycount={ tallyCount } data-color={ color } />
);
jest.mock('./TallyGroup', () => ({ tallyCount, color }) => (
<tally-group-mock
data-testid="tally-group"
data-tallycount={tallyCount}
data-color={color}
/>
));

describe('TallyCount', () => {
describe('score', () => {
Expand Down Expand Up @@ -38,17 +42,17 @@ describe('TallyCount', () => {
it('renders two tallygroups in the correct order when score is 8', () => {
render(<TallyCount color="primary" score={8} />);

// Because we're querying ALL, we can expect the order of the array to match what is
// Because we're querying ALL, we can expect the order of the array to match what is
// rendered in the view. QueryAllByTestId reads the DOM tree from top to bottom.
const tallyGroups = screen.queryAllByTestId('tally-group');
expect(tallyGroups[0].dataset.tallycount).toBe('5');
expect(tallyGroups[1].dataset.tallycount).toBe('3');
});

it('doesn\'t render two tallygroups in the incorrect order when score is 8', () => {
it("doesn't render two tallygroups in the incorrect order when score is 8", () => {
render(<TallyCount color="primary" score={8} />);

// Because we're querying ALL, we can expect the order of the array to match what is
// Because we're querying ALL, we can expect the order of the array to match what is
// rendered in the view. QueryAllByTestId reads the DOM tree from top to bottom.
const tallyGroups = screen.queryAllByTestId('tally-group');
expect(tallyGroups[0].dataset.tallycount).not.toBe('3');
Expand Down

0 comments on commit ac850cb

Please sign in to comment.