Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Eliminate yarn test spam #1024

Merged
merged 13 commits into from
Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions components/profile_popover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import ProfilePopover from './profile_popover.jsx';
function mapStateToProps(state, ownProps) {
const config = state.entities.general.config;

const showEmailAddress = config.ShowEmailAddress === 'true';
const enableWebrtc = config.EnableWebrtc === 'true';
const enableTimezone = config.ExperimentalTimezone === 'true';

return {
...ownProps,
showEmailAddress,
enableWebrtc,
enableTimezone,
};
Expand Down
6 changes: 5 additions & 1 deletion components/profile_popover/profile_popover.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ class ProfilePopover extends React.Component {
delete popoverProps.hasMention;
delete popoverProps.dispatch;
delete popoverProps.enableWebrtc;
delete popoverProps.enableTimezone;

let webrtc;
const userMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
Expand Down Expand Up @@ -283,7 +284,10 @@ class ProfilePopover extends React.Component {
}

dataContent.push(
<hr className='divider divider--expanded'/>
<hr
key='user-popover-hr'
className='divider divider--expanded'
/>
);

if (this.props.user.position) {
Expand Down
4 changes: 2 additions & 2 deletions components/sidebar/sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ export default class Sidebar extends React.PureComponent {
/**
* Current team object
*/
currentTeam: PropTypes.object.isRequired,
currentTeam: PropTypes.object,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code handles these not being present.


/**
* Current user object
*/
currentUser: PropTypes.object.isRequired,
currentUser: PropTypes.object,

/**
* Number of unread mentions/messages
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"image-webpack-loader": "3.6.0",
"imports-loader": "0.7.1",
"jest": "22.1.4",
"jest-canvas-mock": "1.0.2",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that the doughtnut chart doesn't throw errors about getContext not being defined.

"jest-cli": "22.1.4",
"jquery-deferred": "0.3.1",
"json-loader": "0.5.7",
Expand Down Expand Up @@ -142,6 +143,7 @@
"transformIgnorePatterns": [
"node_modules/(?!react-native|react-router)"
],
"setupFiles": ["jest-canvas-mock"],
"setupTestFrameworkScriptFile": "<rootDir>/tests/setup.js",
"testURL": "http:https://localhost:8065"
},
Expand Down
8 changes: 7 additions & 1 deletion store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {storageRehydrate} from 'actions/storage';
import appReducer from 'reducers';
import {transformSet} from 'store/utils';
import {detect} from 'utils/network.js';
import {ActionTypes} from 'utils/constants.jsx';

function getAppReducer() {
return require('../reducers'); // eslint-disable-line global-require
Expand Down Expand Up @@ -73,7 +74,7 @@ export default function configureStore(initialState) {
const storage = localforage;
const KEY_PREFIX = 'reduxPersist:';

localforage.ready(() => {
localforage.ready().then(() => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See localForage/localForage#722 for more details.

const persistor = persistStore(store, {storage, keyPrefix: KEY_PREFIX, ...options}, () => {
store.dispatch({
type: General.STORE_REHYDRATION_COMPLETE,
Expand Down Expand Up @@ -135,6 +136,11 @@ export default function configureStore(initialState) {
});
}
});
}).catch((error) => {
store.dispatch({
type: ActionTypes.STORE_REHYDRATION_FAILED,
error,
});
});
},
persistOptions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ exports[`components/channel_notifications_modal/ChannelNotificationsModal should
/>
<NotificationSection
expand={false}
memberNotificationLevel="all"
onChange={[Function]}
onSubmit={[Function]}
onUpdateSection={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exports[`components/delete_post_modal should match snapshot for delete_post_moda
"remove": [Function],
}
}
onExited={[Function]}
onExited={[MockFunction]}
onHide={[Function]}
renderBackdrop={[Function]}
restoreFocus={true}
Expand Down Expand Up @@ -122,7 +122,7 @@ exports[`components/delete_post_modal should match snapshot for delete_post_moda
"remove": [Function],
}
}
onExited={[Function]}
onExited={[MockFunction]}
onHide={[Function]}
renderBackdrop={[Function]}
restoreFocus={true}
Expand Down Expand Up @@ -209,4 +209,4 @@ exports[`components/delete_post_modal should match snapshot for delete_post_moda
</button>
</ModalFooter>
</Modal>
`;
`;
4 changes: 2 additions & 2 deletions tests/components/analytics/doughnut_chart.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('components/analytics/doughnut_chart.jsx', () => {
/>
);

expect(Chart).toBeCalledWith(null, {data, options: {}, type: 'doughnut'});
expect(Chart).toBeCalledWith(expect.anything(), {data, options: {}, type: 'doughnut'});
expect(wrapper).toMatchSnapshot();
});

Expand All @@ -51,7 +51,7 @@ describe('components/analytics/doughnut_chart.jsx', () => {
data={data}
/>
);
expect(Chart).toBeCalledWith(null, {data, options: {}, type: 'doughnut'});
expect(Chart).toBeCalledWith(expect.anything(), {data, options: {}, type: 'doughnut'});
expect(wrapper).toMatchSnapshot();
});

Expand Down
60 changes: 52 additions & 8 deletions tests/components/channel_notifications_modal.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,18 @@ describe('components/channel_notifications_modal/ChannelNotificationsModal', ()
show: true,
onHide: () => {}, //eslint-disable-line no-empty-function
channel: {id: 'channel_id', display_name: 'channel_display_name'},
channelMember: {notify_props: {desktop: NotificationLevels.ALL}},
currentUser: {id: 'current_user_id', notify_props: {desktop: NotificationLevels.ALL}},
channelMember: {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required props.

notify_props: {
desktop: NotificationLevels.ALL,
mark_unread: NotificationLevels.ALL,
},
},
currentUser: {
id: 'current_user_id',
notify_props: {
desktop: NotificationLevels.ALL,
},
},
sendPushNotifications: true,
actions: {
updateChannelNotifyProps: () => {}, //eslint-disable-line no-empty-function
Expand Down Expand Up @@ -99,7 +109,12 @@ describe('components/channel_notifications_modal/ChannelNotificationsModal', ()
});

test('should match state on handleSubmitMarkUnreadLevel', () => {
const channelMember = {notify_props: {mark_unread: NotificationLevels.ALL}};
const channelMember = {
notify_props: {
desktop: NotificationLevels.NONE,
mark_unread: NotificationLevels.ALL,
},
};
const props = {...baseProps, channelMember};
const wrapper = shallow(
<ChannelNotificationsModal {...props}/>
Expand All @@ -120,7 +135,12 @@ describe('components/channel_notifications_modal/ChannelNotificationsModal', ()
});

test('should match state on handleUpdateMarkUnreadLevel', () => {
const channelMember = {notify_props: {mark_unread: NotificationLevels.ALL}};
const channelMember = {
notify_props: {
desktop: NotificationLevels.NONE,
mark_unread: NotificationLevels.ALL,
},
};
const props = {...baseProps, channelMember};
const wrapper = shallow(
<ChannelNotificationsModal {...props}/>
Expand All @@ -132,7 +152,12 @@ describe('components/channel_notifications_modal/ChannelNotificationsModal', ()
});

test('should match state on handleUpdateMarkUnreadSection', () => {
const channelMember = {notify_props: {mark_unread: NotificationLevels.ALL}};
const channelMember = {
notify_props: {
desktop: NotificationLevels.NONE,
mark_unread: NotificationLevels.ALL,
},
};
const props = {...baseProps, channelMember};
const wrapper = shallow(
<ChannelNotificationsModal {...props}/>
Expand All @@ -154,7 +179,13 @@ describe('components/channel_notifications_modal/ChannelNotificationsModal', ()
});

test('should match state on handleSubmitPushNotificationLevel', () => {
const channelMember = {notify_props: {push: NotificationLevels.ALL}};
const channelMember = {
notify_props: {
desktop: NotificationLevels.NONE,
mark_unread: NotificationLevels.NONE,
push: NotificationLevels.ALL,
},
};
const props = {...baseProps, channelMember};
const wrapper = shallow(
<ChannelNotificationsModal {...props}/>
Expand All @@ -175,7 +206,13 @@ describe('components/channel_notifications_modal/ChannelNotificationsModal', ()
});

test('should match state on handleUpdatePushNotificationLevel', () => {
const channelMember = {notify_props: {push: NotificationLevels.ALL}};
const channelMember = {
notify_props: {
desktop: NotificationLevels.NONE,
mark_unread: NotificationLevels.NONE,
push: NotificationLevels.ALL,
},
};
const props = {...baseProps, channelMember};
const wrapper = shallow(
<ChannelNotificationsModal {...props}/>
Expand All @@ -187,7 +224,14 @@ describe('components/channel_notifications_modal/ChannelNotificationsModal', ()
});

test('should match state on handleUpdatePushSection', () => {
const channelMember = {notify_props: {push: NotificationLevels.ALL}};
const channelMember = {
notify_props: {
desktop: NotificationLevels.NONE,
mark_unread: NotificationLevels.NONE,
push: NotificationLevels.ALL,
},
};

const props = {...baseProps, channelMember};
const wrapper = shallow(
<ChannelNotificationsModal {...props}/>
Expand Down
1 change: 1 addition & 0 deletions tests/components/create_comment/create_comment.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('components/CreateComment', () => {
const baseProps = {
channelId,
rootId,
rootDeleted: false,
channelMembersCount: 3,
draft: {
message: 'Test message',
Expand Down
33 changes: 21 additions & 12 deletions tests/components/delete_post_modal.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {browserHistory} from 'utils/browser_history';
import DeletePostModal from 'components/delete_post_modal/delete_post_modal.jsx';

describe('components/delete_post_modal', () => {
function emptyFunction() {} //eslint-disable-line no-empty-function

const post = {
id: '123',
message: 'test',
Expand All @@ -23,9 +21,10 @@ describe('components/delete_post_modal', () => {
commentCount: 0,
isRHS: false,
actions: {
deletePost: emptyFunction,
deletePost: jest.fn(),
deleteAndRemovePost: jest.fn(),
},
onHide: emptyFunction,
onHide: jest.fn(),
};

test('should match snapshot for delete_post_modal with 0 comments', () => {
Expand Down Expand Up @@ -56,26 +55,36 @@ describe('components/delete_post_modal', () => {

test('should have called actions.deleteAndRemovePost when handleDelete is called', async () => {
browserHistory.push = jest.fn();
const actions = {deleteAndRemovePost: jest.fn()};
actions.deleteAndRemovePost.mockReturnValueOnce({data: true});
const props = {...baseProps, actions};
const deleteAndRemovePost = jest.fn().mockReturnValueOnce({data: true});
const props = {
...baseProps,
actions: {
deleteAndRemovePost,
},
};
const wrapper = shallow(
<DeletePostModal {...props}/>
);

wrapper.setState({show: true});
wrapper.instance().handleDelete();

await expect(actions.deleteAndRemovePost).toHaveBeenCalledTimes(1);
expect(actions.deleteAndRemovePost).toHaveBeenCalledWith(props.post);
await expect(deleteAndRemovePost).toHaveBeenCalledTimes(1);
expect(deleteAndRemovePost).toHaveBeenCalledWith(props.post);
expect(wrapper.state('show')).toEqual(false);
});

test('should call browserHistory.push on handleDelete with post.id === focusedPostId && channelName', async () => {
browserHistory.push = jest.fn();
const actions = {deleteAndRemovePost: jest.fn()};
actions.deleteAndRemovePost.mockReturnValueOnce({data: true});
const props = {...baseProps, actions, focusedPostId: '123', channelName: 'channel_name', teamName: 'team_name'};
const props = {
...baseProps,
focusedPostId: '123',
channelName: 'channel_name',
teamName: 'team_name',
actions: {
deleteAndRemovePost: jest.fn().mockReturnValueOnce({data: true}),
},
};
const wrapper = shallow(
<DeletePostModal {...props}/>
);
Expand Down
3 changes: 3 additions & 0 deletions tests/components/dot_menu/dot_menu_empty.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('components/dot_menu/DotMenu returning empty ("")', () => {
setEditingPost: jest.fn(),
pinPost: jest.fn(),
unpinPost: jest.fn(),
openModal: jest.fn(),
},
};

Expand All @@ -52,6 +53,7 @@ describe('components/dot_menu/DotMenu returning empty ("")', () => {
setEditingPost: jest.fn(),
pinPost: jest.fn(),
unpinPost: jest.fn(),
openModal: jest.fn(),
},
};

Expand All @@ -72,6 +74,7 @@ describe('components/dot_menu/DotMenu returning empty ("")', () => {
setEditingPost: jest.fn(),
pinPost: jest.fn(),
unpinPost: jest.fn(),
openModal: jest.fn(),
},
};

Expand Down
1 change: 1 addition & 0 deletions tests/components/dot_menu/dot_menu_mobile.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('components/dot_menu/DotMenu on mobile view', () => {
setEditingPost: jest.fn(),
pinPost: jest.fn(),
unpinPost: jest.fn(),
openModal: jest.fn(),
},
};

Expand Down
5 changes: 5 additions & 0 deletions tests/components/navbar/navbar.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ describe('components/navbar/Navbar', () => {
isPinnedPosts: true,
actions: {
showEditChannelHeaderModal: jest.fn(),
toggleLhs: jest.fn(),
closeLhs: jest.fn(),
closeRhs: jest.fn(),
toggleRhsMenu: jest.fn(),
closeRhsMenu: jest.fn(),
},
isLicensed: true,
enableWebrtc: true,
Expand Down
2 changes: 2 additions & 0 deletions tests/components/sidebar/sidebar.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe('component/sidebar/sidebar_channel/SidebarChannel', () => {
EnableXToLeaveChannelsFromLHS: 'false',
SiteName: 'Test site',
},
isOpen: false,
showUnreadSection: false,
publicChannelIds: ['c1', 'c2'],
privateChannelIds: ['c3', 'c4'],
Expand Down Expand Up @@ -108,6 +109,7 @@ describe('component/sidebar/sidebar_channel/SidebarChannel', () => {
},
actions: {
goToChannelById: jest.fn(),
close: jest.fn(),
},
};

Expand Down
1 change: 1 addition & 0 deletions tests/components/sidebar/sidebar_channel.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('component/sidebar/sidebar_channel/SidebarChannel', () => {
offTopicDisplayName: 'Off-Topic',
membersCount: 8,
showUnreadForMsgs: true,
shouldHideChannel: false,
actions: {
savePreferences: jest.fn(),
leaveChannel: jest.fn(),
Expand Down
Loading