fix(client): make academy honesty button disabled (#37453)

This commit is contained in:
Kishore Devaraj
2019-10-22 17:20:33 +05:30
committed by mrugesh
parent 2b5268305a
commit 5b1ee9c177
4 changed files with 104 additions and 15 deletions

View File

@@ -0,0 +1,37 @@
/* global expect jest */
import React from 'react';
import ShallowRenderer from 'react-test-renderer/shallow';
import TestRenderer from 'react-test-renderer';
import Honesty from './Honesty';
import { Button } from '@freecodecamp/react-bootstrap';
describe('<Honesty />', () => {
const renderer = new ShallowRenderer();
const updateIsHonestMock = jest.fn();
test('<Honesty /> snapshot when isHonest is false', () => {
const componentToRender = (
<Honesty isHonest={false} updateIsHonest={updateIsHonestMock} />
);
const component = renderer.render(componentToRender);
expect(component).toMatchSnapshot('Honesty');
});
test('<Honesty /> snapshot when isHonest is true', () => {
const componentToRender = (
<Honesty isHonest={true} updateIsHonest={updateIsHonestMock} />
);
const component = renderer.render(componentToRender);
expect(component).toMatchSnapshot('HonestyAccepted');
});
test('should call updateIsHonest method on clicking agree button', () => {
const root = TestRenderer.create(
<Honesty isHonest={false} updateIsHonest={updateIsHonestMock} />
).root;
root.findByType(Button).props.onClick();
expect(updateIsHonestMock).toHaveBeenCalledWith({ isHonest: true });
});
});