Skip to content

173169085-oneway-trip :create oneway trip #12

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

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"linebreak-style": 0,
"global-require": 0,
"eslint linebreak-style": [0, "error", "windows"],
"eslint no-plusplus": ["off"],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"]}],
"jsx-a11y/control-has-associated-label": [0],
"jsx-a11y/anchor-is-valid": [0],
Expand Down
12 changes: 11 additions & 1 deletion __tests__/Components/Auth/ResetPassword/changePassword.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@ import {
const setup = props => {
const { passwordResetAction, isPasswordUpdated, history, loading } = props;

let historyMock;
if (history) {
historyMock = history;
} else {
historyMock = {
push: jest.fn(),
replace: jest.fn()
};
}

const wrapper = shallow(
<UpdatePassword
passwordResetAction={passwordResetAction}
isPasswordUpdated={isPasswordUpdated}
history={history}
history={historyMock}
loading={loading}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion __tests__/Components/Auth/SignIn/SignIn.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe("Sign in test suite", () => {
expect(dispatch.mock.calls[0][0]).toBeInstanceOf(Function);
});

test("mapStateToProps Should return an object", () => {
it("mapStateToProps Should return an object", () => {
const expectedObject = {
isAuthenticated: false,
loading: false
Expand Down
13 changes: 11 additions & 2 deletions __tests__/Components/Auth/SignUp/SignUp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ import {

const setup = props => {
const { signUpAction, history, status, loading } = props;
let historyMock;
if (history) {
historyMock = history;
} else {
historyMock = {
push: jest.fn(),
replace: jest.fn()
};
}
const wrapper = shallow(
<SignUp
signUpAction={signUpAction}
history={history}
history={historyMock}
status={status}
loading={loading}
/>
Expand Down Expand Up @@ -239,7 +248,7 @@ describe("Sign up test suite", () => {
expect(dispatch.mock.calls[0][0]).toBeInstanceOf(Function);
});

test("mapStateToProps Should return an object", () => {
it("mapStateToProps Should return an object", () => {
const expectedObject = {
status: 400,
loading: false
Expand Down
43 changes: 43 additions & 0 deletions __tests__/Components/CreateTripModal/CreateTripModal.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from "react";
import { shallow } from "enzyme";

import CreateTripModal from "../../../src/Components/CreateTripModal/CreateTripModal.jsx";
import OneWayTripFormContainer from "../../../src/Components/OneWayTripForm/OneWayTripForm.jsx";

describe("CreateTripModal test suite", () => {
let wrapper;
beforeEach(() => {
wrapper = shallow(<CreateTripModal showModal={jest.fn()} />);
});
it("should render with no errors and show one way trip form", () => {
expect(wrapper.length).toBe(1);
expect(wrapper.find(".modal").exists()).toBe(true);
expect(wrapper.find(OneWayTripFormContainer).exists()).toBe(true);
});

it("should simulate change one trip type select", () => {
const tripTypeSelect = wrapper.find("#trip-type-select");
expect(tripTypeSelect.exists()).toBe(true);
tripTypeSelect.simulate("change", {
target: {
value: "return"
}
});
expect(wrapper.find("p").text()).toBe("return form");
tripTypeSelect.simulate("change", {
target: {
value: "multiCity"
}
});
expect(wrapper.find("p").text()).toBe("Multi-city form");
});

it("should simulate onclick event that closes the modal", () => {
const showModal = jest.fn();
const component = shallow(<CreateTripModal showModal={showModal} />);
const closeButton = component.find(".modal-header__close-button");
closeButton.simulate("click");
expect(showModal).toHaveBeenCalledTimes(1);
expect(showModal).toHaveBeenCalledWith(false);
});
});
19 changes: 17 additions & 2 deletions __tests__/Components/Home/Home.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
import React from "react";
import { shallow } from "enzyme";

import LatestTripsContainer from "../../../src/Components/LatestTrips/LatestTrips.jsx";
import CreateTripModal from "../../../src/Components/CreateTripModal/CreateTripModal.jsx";
import Home from "../../../src/Components/Home/Home";

describe("<Home />", () => {
it("it renders home component", () => {
it("renders home component", () => {
const testHome = shallow(<Home />);
expect(testHome.find(".main").length).toEqual(1);
});
it("renders LatestTrips component", () => {
const testHome = shallow(<Home />);
expect(testHome.find("Fragment").length).toEqual(1);
expect(testHome.find(LatestTripsContainer).exists()).toBe(true);
});
it("Should simulate on click metod and display createTripModal", () => {
const wrapper = shallow(<Home />);
expect(wrapper.find(CreateTripModal).exists()).toBe(false);
const createTripButton = wrapper.find(".main__show-button");
expect(createTripButton.exists()).toBe(true);
createTripButton.simulate("click");
expect(wrapper.find(CreateTripModal).exists()).toBe(true);
});
});
Loading