Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes unit tests after upgrade to react-redux v7 #34

Merged
merged 1 commit into from
Aug 4, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions client/src/containers/App/test/app.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ describe('<App />', () => {
expect(received).toEqual(expected);
});
test('should render a <Header /> component as child', () => {
const headerLength = getWrapper(store).dive().find(Header).length;
const headerLength = getWrapper(store).dive().dive().find(Header).length;
expect(headerLength).toEqual(1);
});
test('if user exists render LoggedInView as child but not LoggedOutView', () => {
const deepWrapper = getWrapper(store).dive();
const deepWrapper = getWrapper(store).dive().dive();
const loggedInViewLength = deepWrapper.find(LoggedInView).length;
const loggedOutViewLength = deepWrapper.find(LoggedOutView).length;
const loadingDivLength = deepWrapper.find('.loading').length;
Expand All @@ -41,7 +41,7 @@ describe('<App />', () => {
});
test('if user does not exist and no token render LoggedOutView as child', () => {
const modifiedStore = { user: { currentUser: null } };
const deepWrapper = getWrapper(modifiedStore).dive();
const deepWrapper = getWrapper(modifiedStore).dive().dive();
deepWrapper.setState({ isTokenMissing: true });
const loggedInViewLength = deepWrapper.find(LoggedInView).length;
const loggedOutViewLength = deepWrapper.find(LoggedOutView).length;
Expand All @@ -52,7 +52,7 @@ describe('<App />', () => {
});
test('if user does not exist and token exists render LoggedOutView as child', () => {
const modifiedStore = { user: { currentUser: null } };
const deepWrapper = getWrapper(modifiedStore).dive();
const deepWrapper = getWrapper(modifiedStore).dive().dive();
deepWrapper.setState({ isTokenMissing: false });
const loggedInViewLength = deepWrapper.find(LoggedInView).length;
const loggedOutViewLength = deepWrapper.find(LoggedOutView).length;
Expand All @@ -62,7 +62,7 @@ describe('<App />', () => {
expect(loadingDivLength).toEqual(1);
});
test('should map currentUser from state to props', () => {
const received = getWrapper(store).prop('currentUser');
const received = getWrapper(store).prop('children').props.currentUser;
const expected = store.user.currentUser;
expect(received).toEqual(expected);
});
Expand Down
4 changes: 2 additions & 2 deletions client/src/containers/CreateDraft/test/createDraft.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ describe('<CreateDraft />', () => {
expect(received).toEqual(expected);
});
test('should render a <Form /> component as child if form not submitted yet', () => {
const deepWrapper = wrapper.dive();
const deepWrapper = wrapper.dive().dive();
deepWrapper.setState({ isSubmitComplete: false });
const formLength = deepWrapper.find(Form).length;
expect(formLength).toEqual(1);
});
test('should not render <Form /> component as child if form submitted', () => {
const deepWrapper = wrapper.dive();
const deepWrapper = wrapper.dive().dive();
deepWrapper.setState({ isSubmitComplete: true });
const formLength = deepWrapper.find(Form).length;
expect(formLength).toEqual(0);
Expand Down
4 changes: 2 additions & 2 deletions client/src/containers/CreatePlayer/test/createPlayer.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ describe('<CreatePlayer />', () => {
expect(received).toEqual(expected);
});
test('should render a <Form /> component as child if form not submitted yet', () => {
const deepWrapper = wrapper.dive();
const deepWrapper = wrapper.dive().dive();
deepWrapper.setState({ isSubmitComplete: false });
const formLength = deepWrapper.find(Form).length;
expect(formLength).toEqual(1);
});
test('should not render <Form /> component as child if form submitted', () => {
const deepWrapper = wrapper.dive();
const deepWrapper = wrapper.dive().dive();
deepWrapper.setState({ isSubmitComplete: true });
const formLength = deepWrapper.find(Form).length;
expect(formLength).toEqual(0);
Expand Down
14 changes: 7 additions & 7 deletions client/src/containers/CreateTeam/test/createTeam.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ describe('<CreateTeam />', () => {
expect(received).toEqual(expected);
});
test('should render a <Form /> component as child if form not submitted yet', () => {
const deepWrapper = wrapper.dive();
const deepWrapper = wrapper.dive().dive();
deepWrapper.setState({ isSubmitComplete: false });
const formLength = deepWrapper.find(Form).length;
expect(formLength).toEqual(1);
});
test('should not render <Form /> component as child if form submitted', () => {
const deepWrapper = wrapper.dive();
const deepWrapper = wrapper.dive().dive();
deepWrapper.setState({ isSubmitComplete: true });
const formLength = deepWrapper.find(Form).length;
expect(formLength).toEqual(0);
Expand All @@ -57,7 +57,7 @@ describe('<CreateTeam />', () => {
describe('createTeamForDraft', () => {
const createTeamMock = mockActionFn;
test('calls createTeam action with page ID param if exists', () => {
const deepWrapper = wrapper.dive();
const deepWrapper = wrapper.dive().dive();
const { createTeamForDraft } = deepWrapper.instance();
deepWrapper.setProps({
createTeam: createTeamMock,
Expand All @@ -71,7 +71,7 @@ describe('<CreateTeam />', () => {
});
});
test('calls createTeam action with ID from selected button if no page ID param', () => {
const deepWrapper = wrapper.dive();
const deepWrapper = wrapper.dive().dive();
const { createTeamForDraft } = deepWrapper.instance();
deepWrapper.setProps({ createTeam: createTeamMock });
createTeamForDraft('Sharks', 'FooDraft');
Expand All @@ -82,7 +82,7 @@ describe('<CreateTeam />', () => {
});
});
test('cancels call and displays error if missing field', () => {
const deepWrapper = wrapper.dive();
const deepWrapper = wrapper.dive().dive();
const { createTeamForDraft } = deepWrapper.instance();
deepWrapper.setProps({ createTeam: createTeamMock });
createTeamForDraft('Sharks', null);
Expand All @@ -93,7 +93,7 @@ describe('<CreateTeam />', () => {
describe('createRequestToJoinDraft', () => {
const createRequestMock = mockActionFn;
test('calls createRequest action if payload is correct', () => {
const deepWrapper = wrapper.dive();
const deepWrapper = wrapper.dive().dive();
const { createRequestToJoinDraft } = deepWrapper.instance();
deepWrapper.setProps({ createRequest: createRequestMock });
createRequestToJoinDraft('Sharks', 'FooDraft');
Expand All @@ -104,7 +104,7 @@ describe('<CreateTeam />', () => {
});
});
test('cancels call and displays error if missing field', () => {
const deepWrapper = wrapper.dive();
const deepWrapper = wrapper.dive().dive();
const { createRequestToJoinDraft } = deepWrapper.instance();
deepWrapper.setProps({ createRequest: createRequestMock });
createRequestToJoinDraft(null, 'FooDraft');
Expand Down
4 changes: 2 additions & 2 deletions client/src/containers/DraftMenu/test/draftMenu.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('<DraftMenu />', () => {
test(
'should render a <Requests /> component as child if ids from currentUser and currentDraft match',
() => {
const requestsLength = wrapper.dive().find(Requests).length;
const requestsLength = wrapper.dive().dive().find(Requests).length;
expect(requestsLength).toEqual(1);
},
);
Expand All @@ -46,7 +46,7 @@ describe('<DraftMenu />', () => {
const clonedStore = { ...store };
clonedStore.draft.currentDraft.ownerUserId = 'ghi789';
const modifiedWrapper = shallow(<DraftMenu {...props} store={mockStore(clonedStore)} />);
const requestsLength = modifiedWrapper.dive().find(Requests).length;
const requestsLength = modifiedWrapper.dive().dive().find(Requests).length;
expect(requestsLength).toEqual(0);
},
);
Expand Down
15 changes: 12 additions & 3 deletions client/src/containers/Drafts/test/drafts.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ const mockStore = configureStore([thunk]);

const store = {
draft: {
drafts: [{ foo: 'bar' }],
drafts: [
{
uuid: 'abc123',
name: 'Foo',
User: {
firstName: 'Al',
lastName: 'Ali',
},
},
],
},
};

Expand All @@ -24,13 +33,13 @@ describe('<Drafts />', () => {
expect(received).toEqual(expected);
});
test('Renders table as child if drafts exist', () => {
const deepWrapper = getWrapper(store).dive();
const deepWrapper = getWrapper(store).dive().dive();
const tableLength = deepWrapper.find(Table).length;
expect(tableLength).toEqual(1);
});
test('Does not render table as child if no drafts exist', () => {
const modifiedStore = { draft: { drafts: null } };
const deepWrapper = getWrapper(modifiedStore).dive();
const deepWrapper = getWrapper(modifiedStore).dive().dive();
const tableLength = deepWrapper.find(Table).length;
expect(tableLength).toEqual(0);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('<LoggedInView />', () => {
test('Renders a styled div component', () => {
const wrapper = shallow(<LoggedInView />);
const received = wrapper.text();
const expected = '<styled.div />';
const expected = '<Switch />';
expect(received).toEqual(expected);
});
});
2 changes: 1 addition & 1 deletion client/src/containers/Login/test/login.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('<LogIn />', () => {
expect(received).toEqual(expected);
});
test('should render a <Form /> component as child', () => {
const formLength = wrapper.dive().find(Form).length;
const formLength = wrapper.dive().dive().find(Form).length;
expect(formLength).toEqual(1);
});
});
4 changes: 2 additions & 2 deletions client/src/containers/Players/test/players.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ describe('<Players />', () => {
expect(received).toEqual(expected);
});
test('Renders table as child if Players exist', () => {
const deepWrapper = getWrapper(store).dive();
const deepWrapper = getWrapper(store).dive().dive();
const tableLength = deepWrapper.find(Table).length;
expect(tableLength).toEqual(1);
});
test('Does not render table as child if no Players exist', () => {
const modifiedStore = { player: { players: null } };
const deepWrapper = getWrapper(modifiedStore).dive();
const deepWrapper = getWrapper(modifiedStore).dive().dive();
const tableLength = deepWrapper.find(Table).length;
expect(tableLength).toEqual(0);
});
Expand Down
4 changes: 2 additions & 2 deletions client/src/containers/Requests/test/requests.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ describe('<Requests />', () => {
expect(received).toEqual(expected);
});
test('Renders table as child if drafts exist', () => {
const deepWrapper = getWrapper(store).dive();
const deepWrapper = getWrapper(store).dive().dive();
const tableLength = deepWrapper.find(Table).length;
expect(tableLength).toEqual(1);
});
test('Does not render table as child if no drafts exist', () => {
const modifiedStore = { request: { requestsForDraft: null } };
const deepWrapper = getWrapper(modifiedStore).dive();
const deepWrapper = getWrapper(modifiedStore).dive().dive();
const tableLength = deepWrapper.find(Table).length;
expect(tableLength).toEqual(0);
});
Expand Down
14 changes: 9 additions & 5 deletions client/src/containers/TeamMenu/test/teamMenu.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ const mockStore = configureStore([thunk]);

const store = {
team: {
users: [],
teams: [{ uuid: 'abc123', name: 'Foo' }],
drafts: [],
currentTeam: {
uuid: 'abc123',
name: 'Foo',
User: {
firstName: 'Al Ali',
},
},
},
};

Expand All @@ -35,11 +39,11 @@ describe('<TeamMenu />', () => {
expect(received).toEqual(expected);
});
test('should render a <Drafts /> component as child', () => {
const draftsLength = wrapper.dive().find(Drafts).length;
const draftsLength = wrapper.dive().dive().find(Drafts).length;
expect(draftsLength).toEqual(1);
});
test('should render a <Players /> component as child', () => {
const playersLength = wrapper.dive().find(Players).length;
const playersLength = wrapper.dive().dive().find(Players).length;
expect(playersLength).toEqual(1);
});
});
21 changes: 15 additions & 6 deletions client/src/containers/Teams/test/teams.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@ const mockStore = configureStore([thunk]);

const store = {
team: {
teams: [{ foo: 'bar' }],
},
draft: {
drafts: [],
teams: [
{
uuid: 'abc123',
name: 'Foo',
User: {
firstName: 'Al',
lastName: 'Ali',
},
Draft: {
name: 'Bar',
},
},
],
},
};

Expand All @@ -27,13 +36,13 @@ describe('<Teams />', () => {
expect(received).toEqual(expected);
});
test('Renders table as child if teams exist', () => {
const deepWrapper = getWrapper(store).dive();
const deepWrapper = getWrapper(store).dive().dive();
const tableLength = deepWrapper.find(Table).length;
expect(tableLength).toEqual(1);
});
test('Does not render table as child if no teams exist', () => {
const modifiedStore = { ...store, team: { teams: null } };
const deepWrapper = getWrapper(modifiedStore).dive();
const deepWrapper = getWrapper(modifiedStore).dive().dive();
const tableLength = deepWrapper.find(Table).length;
expect(tableLength).toEqual(0);
});
Expand Down