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

@ -24,9 +24,14 @@ class Honesty extends Component {
);
renderIsHonestAgreed = () => (
<Panel bsStyle='info' className='agreed btn'>
<Button
block={true}
bsStyle='primary'
className='disabled-agreed'
disabled={true}
>
<p>You have accepted our Academic Honesty Policy.</p>
</Panel>
</Button>
);
render() {

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 });
});
});

View File

@ -0,0 +1,59 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Honesty /> <Honesty /> snapshot when isHonest is false: Honesty 1`] = `
<section
className="honesty-policy"
>
<SectionHeader>
Academic Honesty Policy
</SectionHeader>
<FullWidthRow>
<Uncontrolled(Panel)
className="honesty-panel"
>
<HonestyPolicy />
</Uncontrolled(Panel)>
<br />
<Button
active={false}
block={true}
bsClass="btn"
bsStyle="primary"
disabled={false}
onClick={[Function]}
>
Agree
</Button>
</FullWidthRow>
</section>
`;
exports[`<Honesty /> <Honesty /> snapshot when isHonest is true: HonestyAccepted 1`] = `
<section
className="honesty-policy"
>
<SectionHeader>
Academic Honesty Policy
</SectionHeader>
<FullWidthRow>
<Uncontrolled(Panel)
className="honesty-panel"
>
<HonestyPolicy />
</Uncontrolled(Panel)>
<br />
<Button
active={false}
block={true}
bsClass="btn"
bsStyle="primary"
className="disabled-agreed"
disabled={true}
>
<p>
You have accepted our Academic Honesty Policy.
</p>
</Button>
</FullWidthRow>
</section>
`;

View File

@ -8,19 +8,7 @@
padding-top: 15px;
}
.honesty-policy .agreed {
display: flex;
justify-content: center;
align-items: center;
background-color: var(--quaternary-color);
color: #fff;
}
div .agreed p {
color: white;
}
.honesty-policy .agreed p {
.honesty-policy .disabled-agreed p {
margin-top: 0;
margin-bottom: 0;
}