Skip to content

Commit

Permalink
fix(coverage): bump code coverage to 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardoalemax committed Aug 22, 2021
1 parent 6890717 commit 1b91676
Show file tree
Hide file tree
Showing 8 changed files with 594 additions and 81 deletions.
52 changes: 51 additions & 1 deletion src/__tests__/app/components/Display.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ test('renders element properly with fist type list', () => {
`);
});

test('renders element properly with more data filled list', () => {
test('renders element properly with more data filled list with no selected', () => {
const select = jest.fn();

const { container } = render(
Expand Down Expand Up @@ -103,3 +103,53 @@ test('renders element properly with more data filled list', () => {
fireEvent.click(screen.getByText('voltorb'));
expect(select).toHaveBeenCalledWith(Voltorb);
});

test('renders element properly with more data filled list selected', () => {
const select = jest.fn();

const { container } = render(
<Display
list={[{ ...(Voltorb as any) }]}
select={select}
selected={Voltorb as any}
className=""
/>
);

expect(container).toMatchInlineSnapshot(`
<div>
<div
class="sc-bdnxRM kBUBdL"
>
<div
class="sc-gtsrHT cCFGuB selected"
>
<div
class="sc-dlnjwi kenTwt"
>
#
100
</div>
<img
alt="sprit"
src="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/100.png"
/>
<div
class="sc-hKFxyN lmoTsb"
>
voltorb
</div>
<div
class="sc-eCApnc crGkvA electric"
>
electric
</div>
</div>
</div>
</div>
`);

expect(screen.getByText('voltorb')).toBeInTheDocument();
fireEvent.click(screen.getByText('voltorb'));
expect(select).toHaveBeenCalledWith(Voltorb);
});
318 changes: 318 additions & 0 deletions src/__tests__/app/components/Info.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,318 @@
import { render } from '@testing-library/react';

import Info from '../../../app/components/Info';
import Voltorb from '../../fixtures/voltorb.json';

test('renders element properly with no state', () => {
const { container } = render(<Info />);

expect(container).toMatchInlineSnapshot(`
<div>
<div
class="sc-bdnxRM ivojsm"
/>
</div>
`);
});

test('renders element properly with no state', () => {
const { container } = render(
<Info selected={{ name: 'Voltorb', url: 'poke-url' }} />
);

expect(container).toMatchInlineSnapshot(`
<div>
<div
class="sc-bdnxRM ivojsm selected"
>
<div
class="sc-eCApnc cwKgEi"
>
#
-
Voltorb
</div>
<div
class="sc-gtsrHT dCEJzY"
>
<div
class="sc-hKFxyN bokGSv"
>
<div
class="sc-jSFjdj frluGN"
>
<img
alt="pokeview"
/>
</div>
<div
class="sc-pNWdM jPvjWT"
/>
</div>
<div
class="sc-dlnjwi jGxdcE"
>
<div
class="sc-gKAaRy eRcPzA"
/>
<div
class="sc-iCoGMd hutXq"
/>
</div>
</div>
</div>
</div>
`);
});

test('renders element properly with all state without flavor text', () => {
const { container } = render(
<Info
selected={{
...(Voltorb as any),
species: {
flavor_text_entries: [
{
flavor_text: '',
language: { name: 'en' },
},
],
},
}}
/>
);

expect(container).toMatchInlineSnapshot(`
<div>
<div
class="sc-bdnxRM ivojsm selected"
>
<div
class="sc-eCApnc cwKgEi"
>
#
100
-
voltorb
</div>
<div
class="sc-gtsrHT dCEJzY"
>
<div
class="sc-hKFxyN bokGSv"
>
<div
class="sc-jSFjdj frluGN"
>
<img
alt="pokeview"
src="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/100.png"
/>
</div>
<div
class="sc-pNWdM jPvjWT"
>
<span
class="sc-dIsUp fjMNcB electric"
>
electric
</span>
</div>
</div>
<div
class="sc-dlnjwi jGxdcE"
>
<div
class="sc-gKAaRy eRcPzA"
/>
<div
class="sc-iCoGMd hutXq"
>
<div
class="sc-fujyAs dVXZnr"
>
hp
:
<span>
40
</span>
</div>
<div
class="sc-fujyAs dVXZnr"
>
attack
:
<span>
30
</span>
</div>
<div
class="sc-fujyAs dVXZnr"
>
defense
:
<span>
50
</span>
</div>
<div
class="sc-fujyAs dVXZnr"
>
special-attack
:
<span>
55
</span>
</div>
<div
class="sc-fujyAs dVXZnr"
>
special-defense
:
<span>
55
</span>
</div>
<div
class="sc-fujyAs dVXZnr"
>
speed
:
<span>
100
</span>
</div>
</div>
</div>
</div>
</div>
</div>
`);
});

test('renders element properly with all state', () => {
const { container } = render(
<Info
selected={{
...(Voltorb as any),
species: {
flavor_text_entries: [
{
flavor_text: 'Voltorb is the best for test',
language: { name: 'en' },
},
],
},
}}
/>
);

expect(container).toMatchInlineSnapshot(`
<div>
<div
class="sc-bdnxRM ivojsm selected"
>
<div
class="sc-eCApnc cwKgEi"
>
#
100
-
voltorb
</div>
<div
class="sc-gtsrHT dCEJzY"
>
<div
class="sc-hKFxyN bokGSv"
>
<div
class="sc-jSFjdj frluGN"
>
<img
alt="pokeview"
src="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/100.png"
/>
</div>
<div
class="sc-pNWdM jPvjWT"
>
<span
class="sc-dIsUp fjMNcB electric"
>
electric
</span>
</div>
</div>
<div
class="sc-dlnjwi jGxdcE"
>
<div
class="sc-gKAaRy eRcPzA"
>
Voltorb is the best for test
</div>
<div
class="sc-iCoGMd hutXq"
>
<div
class="sc-fujyAs dVXZnr"
>
hp
:
<span>
40
</span>
</div>
<div
class="sc-fujyAs dVXZnr"
>
attack
:
<span>
30
</span>
</div>
<div
class="sc-fujyAs dVXZnr"
>
defense
:
<span>
50
</span>
</div>
<div
class="sc-fujyAs dVXZnr"
>
special-attack
:
<span>
55
</span>
</div>
<div
class="sc-fujyAs dVXZnr"
>
special-defense
:
<span>
55
</span>
</div>
<div
class="sc-fujyAs dVXZnr"
>
speed
:
<span>
100
</span>
</div>
</div>
</div>
</div>
</div>
</div>
`);
});
Loading

0 comments on commit 1b91676

Please sign in to comment.