From 5b1ee9c177198644db308b6fe441c97100e8d098 Mon Sep 17 00:00:00 2001 From: Kishore Devaraj Date: Tue, 22 Oct 2019 17:20:33 +0530 Subject: [PATCH] fix(client): make academy honesty button disabled (#37453) --- client/src/components/settings/Honesty.js | 9 ++- .../src/components/settings/Honesty.test.js | 37 ++++++++++++ .../__snapshots__/Honesty.test.js.snap | 59 +++++++++++++++++++ client/src/components/settings/honesty.css | 14 +---- 4 files changed, 104 insertions(+), 15 deletions(-) create mode 100644 client/src/components/settings/Honesty.test.js create mode 100644 client/src/components/settings/__snapshots__/Honesty.test.js.snap diff --git a/client/src/components/settings/Honesty.js b/client/src/components/settings/Honesty.js index 93020372dd..fdb126bafb 100644 --- a/client/src/components/settings/Honesty.js +++ b/client/src/components/settings/Honesty.js @@ -24,9 +24,14 @@ class Honesty extends Component { ); renderIsHonestAgreed = () => ( - + ); render() { diff --git a/client/src/components/settings/Honesty.test.js b/client/src/components/settings/Honesty.test.js new file mode 100644 index 0000000000..173a582082 --- /dev/null +++ b/client/src/components/settings/Honesty.test.js @@ -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('', () => { + const renderer = new ShallowRenderer(); + const updateIsHonestMock = jest.fn(); + + test(' snapshot when isHonest is false', () => { + const componentToRender = ( + + ); + const component = renderer.render(componentToRender); + expect(component).toMatchSnapshot('Honesty'); + }); + + test(' snapshot when isHonest is true', () => { + const componentToRender = ( + + ); + const component = renderer.render(componentToRender); + expect(component).toMatchSnapshot('HonestyAccepted'); + }); + + test('should call updateIsHonest method on clicking agree button', () => { + const root = TestRenderer.create( + + ).root; + + root.findByType(Button).props.onClick(); + expect(updateIsHonestMock).toHaveBeenCalledWith({ isHonest: true }); + }); +}); diff --git a/client/src/components/settings/__snapshots__/Honesty.test.js.snap b/client/src/components/settings/__snapshots__/Honesty.test.js.snap new file mode 100644 index 0000000000..4922910f5b --- /dev/null +++ b/client/src/components/settings/__snapshots__/Honesty.test.js.snap @@ -0,0 +1,59 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` snapshot when isHonest is false: Honesty 1`] = ` +
+ + Academic Honesty Policy + + + + + +
+ +
+
+`; + +exports[` snapshot when isHonest is true: HonestyAccepted 1`] = ` +
+ + Academic Honesty Policy + + + + + +
+ +
+
+`; diff --git a/client/src/components/settings/honesty.css b/client/src/components/settings/honesty.css index bcf898af2f..0e2c7b36d4 100644 --- a/client/src/components/settings/honesty.css +++ b/client/src/components/settings/honesty.css @@ -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; }