Skip to content

Commit 0a0e806

Browse files
committed
Fix tests & remove underscore
1 parent 78a631f commit 0a0e806

File tree

5 files changed

+47
-11
lines changed

5 files changed

+47
-11
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@
8585
"redux-storage-decorator-filter": "=1.1.8",
8686
"redux-storage-engine-localstorage": "=1.1.4",
8787
"redux-storage-merger-immutablejs": "=1.0.5",
88-
"redux-thunk": "=2.2.0",
89-
"underscore": "=1.8.3"
88+
"redux-thunk": "=2.2.0"
9089
},
9190
"devDependencies": {
9291
"babel-eslint": "=7.2.3",

src/js/__tests__/routes/__snapshots__/notifications.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`routes/notification.js should render itself & its children 1`] = `
3+
exports[`routes/notification.js should render itself & its children (with notifications) 1`] = `
44
<div
55
className="container-fluid main-container notifications"
66
>

src/js/__tests__/routes/notifications.js

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react'; // eslint-disable-line no-unused-vars
2-
import { Map } from 'immutable';
2+
import { List, Map } from 'immutable';
33
import renderer from 'react-test-renderer';
4+
import { shallow } from 'enzyme';
45

56
import { NotificationsRoute, mapStateToProps } from '../../routes/notifications';
67
import { mockedNotificationsRecuderData } from '../../__mocks__/mockedData';
@@ -10,7 +11,8 @@ jest.mock('../../components/notifications');
1011
describe('routes/notification.js', () => {
1112
const props = {
1213
failed: false,
13-
accountNotifications: mockedNotificationsRecuderData
14+
accountNotifications: mockedNotificationsRecuderData,
15+
hasNotifications: true,
1416
};
1517

1618
it('should test the mapStateToProps method', () => {
@@ -25,13 +27,43 @@ describe('routes/notification.js', () => {
2527

2628
expect(mappedProps.failed).toBeFalsy();
2729
expect(mappedProps.accountNotifications).toEqual(mockedNotificationsRecuderData);
30+
expect(mappedProps.hasNotifications).toBeTruthy();
2831
});
2932

30-
it('should render itself & its children', () => {
33+
it('should render itself & its children (with notifications)', () => {
3134
const tree = renderer.create(
3235
<NotificationsRoute {...props} />
3336
);
3437

3538
expect(tree).toMatchSnapshot();
3639
});
40+
41+
it('should render itself & its children (all read notifications)', () => {
42+
const caseProps = {
43+
...props,
44+
hasNotifications: false,
45+
accountNotifications: List(),
46+
};
47+
48+
const wrapper = shallow(
49+
<NotificationsRoute {...caseProps} />
50+
);
51+
52+
expect(wrapper).toBeDefined();
53+
expect(wrapper.find('AllRead')).toHaveLength(1);
54+
});
55+
56+
it('should render itself & its children (error page - oops)', () => {
57+
const caseProps = {
58+
...props,
59+
failed: true,
60+
};
61+
62+
const wrapper = shallow(
63+
<NotificationsRoute {...caseProps} />
64+
);
65+
66+
expect(wrapper).toBeDefined();
67+
expect(wrapper.find('Oops')).toHaveLength(1);
68+
});
3769
});

src/js/components/all-read.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import _ from 'underscore';
21
import React from 'react';
32
import malarkey from 'malarkey';
43
import {emojify} from 'react-emojione';
@@ -7,7 +6,9 @@ import constants from '../utils/constants';
76

87
export default class AllRead extends React.PureComponent {
98
componentDidMount() {
10-
const message = _.sample(constants.ALLREAD_MESSAGES);
9+
const message = constants.ALLREAD_MESSAGES[
10+
Math.floor(Math.random() * constants.ALLREAD_MESSAGES.length)
11+
];
1112

1213
const elem = document.querySelector('.typed');
1314
const opts = {
@@ -20,7 +21,9 @@ export default class AllRead extends React.PureComponent {
2021
}
2122

2223
render() {
23-
const emoji = _.sample(constants.ALLREAD_EMOJIS);
24+
const emoji = constants.ALLREAD_EMOJIS[
25+
Math.floor(Math.random() * constants.ALLREAD_EMOJIS.length)
26+
];
2427

2528
return (
2629
<div className="container-fluid main-container notifications all-read">

src/js/components/oops.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import _ from 'underscore';
21
import React from 'react';
32
import {emojify} from 'react-emojione';
43

54
import constants from '../utils/constants';
65

76
export default class Oops extends React.PureComponent {
87
render() {
9-
const emoji = _.sample(constants.ERROR_EMOJIS);
8+
const emoji = constants.ERROR_EMOJIS[
9+
Math.floor(Math.random() * constants.ERROR_EMOJIS.length)
10+
];
11+
1012

1113
return (
1214
<div className="container-fluid main-container notifications errored">

0 commit comments

Comments
 (0)