Skip to content

Commit

Permalink
Merge pull request #227 from labzero/develop
Browse files Browse the repository at this point in the history
Merge to master
  • Loading branch information
JeffreyATW authored Sep 18, 2018
2 parents 487b7bf + bb1e49a commit 8258654
Show file tree
Hide file tree
Showing 8 changed files with 510 additions and 567 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"browserslist": [">1%", "last 4 versions", "Firefox ESR", "not ie < 9"],
"dependencies": {
"@babel/polyfill": "^7.0.0-beta.44",
"bcrypt": "^1.0.3",
"bcrypt": "^3.0.0",
"bluebird": "^3.5.1",
"body-parser": "^1.18.2",
"classnames": "^2.2.5",
Expand Down
87 changes: 87 additions & 0 deletions src/components/AddUserForm/AddUserForm.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/* eslint-env mocha */
/* eslint-disable no-unused-expressions */
import React from 'react';
import { expect } from 'chai';
import { shallow } from 'enzyme';
import AddUserForm from './AddUserForm';

describe('AddUserForm', () => {
let props;

beforeEach(() => {
props = {
intl: {
formatMessage: () => {}
}
};
});

describe('the options for the User Type form', () => {
it('includes an option for guest if the hasGuestRole prop is true', () => {
props.hasGuestRole = true;

const wrapper = shallow(<AddUserForm {...props} />);

expect(wrapper.contains(<option value="guest" />)).to.be.true;
});

it('does not include an option for guest if the hasGuestRole prop is false', () => {
props.hasGuestRole = false;

const wrapper = shallow(<AddUserForm {...props} />);

expect(wrapper.contains(<option value="guest" />)).to.be.false;
});

it('includes an option for member if the hasMemberRole prop is true', () => {
props.hasMemberRole = true;

const wrapper = shallow(<AddUserForm {...props} />);

expect(wrapper.contains(<option value="member" />)).to.be.true;
});

it('does not include an option for member if the hasMemberRole prop is false', () => {
props.hasMemberRole = false;

const wrapper = shallow(<AddUserForm {...props} />);

expect(wrapper.contains(<option value="member" />)).to.be.false;
});

it('includes an option for owner if the hasOwnerRole prop is true', () => {
props.hasOwnerRole = true;

const wrapper = shallow(<AddUserForm {...props} />);

expect(wrapper.contains(<option value="owner" />)).to.be.true;
});

it('does not include an option for owner if the hasOwnerRole prop is false', () => {
props.hasOwnerRole = false;

const wrapper = shallow(<AddUserForm {...props} />);

expect(wrapper.contains(<option value="owner" />)).to.be.false;
});
});

describe('the HelpBlock for the AddUserForm', () => {
const ownerHelpString = ' Owners can manage all user roles and manage overall team information.';
it('contains additional guidance for owners if the hasOwnerRole is true', () => {
props.hasOwnerRole = true;

const wrapper = shallow(<AddUserForm {...props} />);

expect(wrapper.contains(ownerHelpString)).to.be.true;
});

it('does not contain additional guidance for owners if the hasOwnerRole is false', () => {
props.hasOwnerRole = false;

const wrapper = shallow(<AddUserForm {...props} />);

expect(wrapper.contains(ownerHelpString)).to.be.false;
});
});
});
4 changes: 3 additions & 1 deletion src/components/Html.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Html extends Component {
apikey: PropTypes.string,
app: PropTypes.object, // eslint-disable-line
title: PropTypes.string.isRequired,
ogTitle: PropTypes.string.isRequired,
description: PropTypes.string.isRequired,
root: PropTypes.string,
styles: PropTypes.arrayOf(PropTypes.shape({
Expand All @@ -41,6 +42,7 @@ class Html extends Component {
apikey,
app,
title,
ogTitle,
description,
root,
styles,
Expand All @@ -65,7 +67,7 @@ class Html extends Component {
<meta httpEquiv="x-ua-compatible" content="ie=edge" />
<title>{title}</title>
<meta name="description" content={description} />
<meta property="og:title" content={title} />
<meta property="og:title" content={ogTitle} />
<meta property="og:description" content={description} />
<meta property="og:image" content={`${root}/tile.png`} />
<meta property="og:site_name" content="Lab Zero" />
Expand Down
59 changes: 57 additions & 2 deletions src/components/Layout/Layout.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,21 @@
import React from 'react';
import { expect } from 'chai';
import { shallow } from 'enzyme';
import Layout from './Layout';
import proxyquire from 'proxyquire';

const context = { insertCss: () => {} };

describe('App', () => {
const proxy = proxyquire.noCallThru();

const FooterContainer = () => <div>Stubbed footer container.</div>;
const ConfirmModalContainer = () => <div>Stubbed confirm modal container.</div>;

const Layout = proxy('./Layout', {
'../Footer/FooterContainer': FooterContainer,
'../ConfirmModal/ConfirmModalContainer': ConfirmModalContainer
}).default;

describe('Layout', () => {
let props;

beforeEach(() => {
Expand All @@ -36,4 +46,49 @@ describe('App', () => {

expect(wrapper.contains(<div className="child" />)).to.be.true;
});

it('does not render the FooterContainer component if the isHome prop is true', () => {
props.isHome = true;
const wrapper = shallow(
<Layout {...props} />,
{ context });

expect(wrapper.find('FooterContainer')).to.have.length(0);
});

it('renders the FooterContainer component if the isHome prop is false', () => {
props.isHome = false;

const wrapper = shallow(
<Layout {...props} />,
{ context });

expect(wrapper.find('FooterContainer')).to.have.length(1);
});

it('renders the FooterContainer component if the isHome prop is left undefined', () => {
const wrapper = shallow(
<Layout {...props} />,
{ context });

expect(wrapper.find('FooterContainer')).to.have.length(1);
});

it('renders the ConfirmModalContainer component if the confirmShown prop is set to true', () => {
props.confirmShown = true;
const wrapper = shallow(
<Layout {...props} />,
{ context });

expect(wrapper.find('ConfirmModalContainer')).to.have.length(1);
});

it('does not render the ConfirmModalContainer component if the confirmShown prop is set to false', () => {
props.confirmShown = false;
const wrapper = shallow(
<Layout {...props} />,
{ context });

expect(wrapper.find('ConfirmModalContainer')).to.have.length(0);
});
});
1 change: 1 addition & 0 deletions src/components/NotificationList/NotificationList.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
margin: 1em;
max-width: 300px;
transition: height .5s;
z-index: 1; // at same level as page-root-layer
}

.notificationContainer {
Expand Down
1 change: 1 addition & 0 deletions src/routes/login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function action(context) {
</LayoutContainer>
),
title: 'Log in',
ogTitle: 'Lunch'
}));
}

Expand Down
5 changes: 4 additions & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,12 @@ const render = async (req, res, next) => {
return;
}

const pageTitle = route.title || 'Lunch';

const data = { ...route,
apikey: process.env.GOOGLE_CLIENT_APIKEY || '',
title: route.title || 'Lunch',
title: pageTitle,
ogTitle: route.ogTitle || pageTitle,
description: 'A simple lunch voting app for you and your team. Search nearby restaurants, add them to your list, vote for as many as you like, and decide on today’s pick!',
body: '',
root: generateUrl(req, req.get('host')),
Expand Down
Loading

0 comments on commit 8258654

Please sign in to comment.