mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-10 18:27:25 +03:00
Created GraphCard test
This commit is contained in:
parent
cb761dea8f
commit
e31e70039d
1 changed files with 49 additions and 0 deletions
49
test/visits/helpers/GraphCard.test.js
Normal file
49
test/visits/helpers/GraphCard.test.js
Normal file
|
@ -0,0 +1,49 @@
|
|||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { Card, CardBody, CardHeader, CardFooter } from 'reactstrap';
|
||||
import GraphCard from '../../../src/visits/helpers/GraphCard';
|
||||
import DefaultChart from '../../../src/visits/helpers/DefaultChart';
|
||||
|
||||
describe('<GraphCard />', () => {
|
||||
let wrapper;
|
||||
const createWrapper = (title = '', footer) => {
|
||||
wrapper = shallow(<GraphCard title={title} footer={footer} />);
|
||||
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
afterEach(() => wrapper && wrapper.unmount());
|
||||
|
||||
it('renders expected components', () => {
|
||||
const wrapper = createWrapper();
|
||||
const card = wrapper.find(Card);
|
||||
const header = wrapper.find(CardHeader);
|
||||
const body = wrapper.find(CardBody);
|
||||
const chart = wrapper.find(DefaultChart);
|
||||
const footer = wrapper.find(CardFooter);
|
||||
|
||||
expect(card).toHaveLength(1);
|
||||
expect(header).toHaveLength(1);
|
||||
expect(body).toHaveLength(1);
|
||||
expect(chart).toHaveLength(1);
|
||||
expect(footer).toHaveLength(0);
|
||||
});
|
||||
|
||||
it.each([
|
||||
[ 'the title', 'the title' ],
|
||||
[ () => 'the title from func', 'the title from func' ],
|
||||
])('properly renders title by parsing provided value', (title, expectedTitle) => {
|
||||
const wrapper = createWrapper(title);
|
||||
const header = wrapper.find(CardHeader);
|
||||
|
||||
expect(header.html()).toContain(expectedTitle);
|
||||
});
|
||||
|
||||
it('renders footer only when provided', () => {
|
||||
const wrapper = createWrapper('', 'the footer');
|
||||
const footer = wrapper.find(CardFooter);
|
||||
|
||||
expect(footer).toHaveLength(1);
|
||||
expect(footer.html()).toContain('the footer');
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue