App.js
· 695 B · JavaScript
Raw
import "./App.css";
import Games from "./pages/home";
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import React, { Component } from "react";
import Booking from "./pages/book";
import Search_Booking from "./pages/search_booking";
class App extends Component {
state = {};
render() {
return (
<div>
<Router>
<div>
<Switch>
<Route exact path="/" component={Games} />
<Route exact path="/booking" component={Booking} />
<Route exact path="/search" component={Search_Booking} />
</Switch>
</div>
</Router>
</div>
);
}
}
export default App;
1 | import "./App.css"; |
2 | import Games from "./pages/home"; |
3 | import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; |
4 | import React, { Component } from "react"; |
5 | import Booking from "./pages/book"; |
6 | import Search_Booking from "./pages/search_booking"; |
7 | class App extends Component { |
8 | state = {}; |
9 | render() { |
10 | return ( |
11 | <div> |
12 | <Router> |
13 | <div> |
14 | <Switch> |
15 | <Route exact path="/" component={Games} /> |
16 | <Route exact path="/booking" component={Booking} /> |
17 | <Route exact path="/search" component={Search_Booking} /> |
18 | </Switch> |
19 | </div> |
20 | </Router> |
21 | </div> |
22 | ); |
23 | } |
24 | } |
25 | |
26 | export default App; |
27 |
Read Only
· 383 B · Text
Raw
## Read-only Files
The following files are marked read-only. You cannot edit these files
in the editor; however, it is possible from the terminal. You must not
modify or delete these files because doing so results in a zero score.
* Node/src/db/defaultDB.js
* src/test/book.test.js
* src/test/home.test.js
* src/test/reducer.test.js
* src/test/search.test.js
* src/test/slot.test.js
1 | ## Read-only Files |
2 | The following files are marked read-only. You cannot edit these files |
3 | in the editor; however, it is possible from the terminal. You must not |
4 | modify or delete these files because doing so results in a zero score. |
5 | |
6 | * Node/src/db/defaultDB.js |
7 | * src/test/book.test.js |
8 | * src/test/home.test.js |
9 | * src/test/reducer.test.js |
10 | * src/test/search.test.js |
11 | * src/test/slot.test.js |
action.js
· 620 B · JavaScript
Raw
Action/action.js
export const selectGame = id => {
return {
type: "SELECT_GAME",
id
};
};
export const onSelectedDay = Day => {
return {
type: "ON_SELECTED_DAY",
Day
};
};
export const doneBooking = Day => {
return {
type: "DONE_BOOKING",
Day
};
};
export const iconClick = () => {
return {
type: "ICON_CLICK"
}
}
export const selectSlot = id => {
return {
type: "ON_SELECT_SLOT",
id
};
};
export const onCLICK = () => {
return {
type: "on_CLICK"
};
};
export const checkBooking = payload => {
return {
type: "CHECK_BOOKING",
payload
};
};
1 | Action/action.js |
2 | |
3 | export const selectGame = id => { |
4 | return { |
5 | type: "SELECT_GAME", |
6 | id |
7 | }; |
8 | }; |
9 | |
10 | export const onSelectedDay = Day => { |
11 | return { |
12 | type: "ON_SELECTED_DAY", |
13 | Day |
14 | }; |
15 | }; |
16 | export const doneBooking = Day => { |
17 | return { |
18 | type: "DONE_BOOKING", |
19 | Day |
20 | }; |
21 | }; |
22 | export const iconClick = () => { |
23 | return { |
24 | type: "ICON_CLICK" |
25 | } |
26 | } |
27 | export const selectSlot = id => { |
28 | return { |
29 | type: "ON_SELECT_SLOT", |
30 | id |
31 | }; |
32 | }; |
33 | |
34 | export const onCLICK = () => { |
35 | return { |
36 | type: "on_CLICK" |
37 | }; |
38 | }; |
39 | |
40 | export const checkBooking = payload => { |
41 | return { |
42 | type: "CHECK_BOOKING", |
43 | payload |
44 | }; |
45 | }; |
46 |
book.js
· 2.3 KiB · JavaScript
Raw
pages/book.js
import React, { Component } from "react";
import DayPicker from "react-day-picker";
import "react-day-picker/lib/style.css";
import icon from "../images/football.svg";
import { connect } from "react-redux";
import { onSelectedDay, doneBooking, iconClick } from "../Action/action";
export class Booking extends Component {
state = {
name: undefined,
contact: undefined,
errorStmt: "",
};
handleHomePage = () => {
};
handleValidation = () => {
};
Display_slot = Day => {
this.props.onSelectedDay(Day);
};
handleBook = () => {
};
render() {
return (
<div className="Home">
<header>
Play Zone:
<img
alt=""
id="icon"
src={icon}
onClick={this.handleHomePage}
width="40px"
height="40px"
/>
<p id="header_Date">
{/* display date */}
</p>
</header>
<div className="Card" id="date">
{/* date picker goes here */}
</div>
<br />
<div>
<div id="slot-display">
{/* code goes here to display slot */}
<div>
{/* code goes here for the name and contact number input fields
each input field has name as name and contact respectively*/}
<div>
{/* code goes here the "Book Now" button with id book_button */}
{/* span to display error statement */}
</div>
</div>
</div>
<p id="not_opened">
Booking has been closed.Book your slot for
{/* code goes here to display the date */}
</p>
<p id="not_opened">Booking is not opened yet</p>
</div>
</div>
);
}
}
const mapStateToProps = state => {
return {
game: state.Games,
selectedGame: state.selectedGame,
selectedDate: state.selectedDate,
slotBooked: state.slotBooked
};
};
const mapDispatchToProps = dispatch => {
return {
doneBooking: () => dispatch(doneBooking()),
onSelectedDay: id => dispatch(onSelectedDay(id)),
iconClick: () => dispatch(iconClick()),
bookingDetails: (details, updatesGame) => dispatch({ type: "BOOKINGS", details, updatesGame }),
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(Booking);
1 | pages/book.js |
2 | |
3 | import React, { Component } from "react"; |
4 | import DayPicker from "react-day-picker"; |
5 | import "react-day-picker/lib/style.css"; |
6 | import icon from "../images/football.svg"; |
7 | import { connect } from "react-redux"; |
8 | import { onSelectedDay, doneBooking, iconClick } from "../Action/action"; |
9 | |
10 | export class Booking extends Component { |
11 | state = { |
12 | name: undefined, |
13 | contact: undefined, |
14 | errorStmt: "", |
15 | }; |
16 | |
17 | handleHomePage = () => { |
18 | |
19 | }; |
20 | |
21 | |
22 | handleValidation = () => { |
23 | |
24 | }; |
25 | |
26 | Display_slot = Day => { |
27 | this.props.onSelectedDay(Day); |
28 | }; |
29 | |
30 | |
31 | handleBook = () => { |
32 | |
33 | }; |
34 | |
35 | render() { |
36 | |
37 | return ( |
38 | <div className="Home"> |
39 | <header> |
40 | Play Zone: |
41 | <img |
42 | alt="" |
43 | id="icon" |
44 | src={icon} |
45 | onClick={this.handleHomePage} |
46 | width="40px" |
47 | height="40px" |
48 | /> |
49 | <p id="header_Date"> |
50 | {/* display date */} |
51 | </p> |
52 | </header> |
53 | |
54 | <div className="Card" id="date"> |
55 | {/* date picker goes here */} |
56 | </div> |
57 | <br /> |
58 | <div> |
59 | <div id="slot-display"> |
60 | {/* code goes here to display slot */} |
61 | <div> |
62 | {/* code goes here for the name and contact number input fields |
63 | each input field has name as name and contact respectively*/} |
64 | |
65 | <div> |
66 | {/* code goes here the "Book Now" button with id book_button */} |
67 | {/* span to display error statement */} |
68 | |
69 | </div> |
70 | </div> |
71 | </div> |
72 | |
73 | <p id="not_opened"> |
74 | Booking has been closed.Book your slot for |
75 | {/* code goes here to display the date */} |
76 | </p> |
77 | |
78 | <p id="not_opened">Booking is not opened yet</p> |
79 | |
80 | </div> |
81 | </div> |
82 | ); |
83 | } |
84 | } |
85 | |
86 | const mapStateToProps = state => { |
87 | return { |
88 | game: state.Games, |
89 | selectedGame: state.selectedGame, |
90 | selectedDate: state.selectedDate, |
91 | slotBooked: state.slotBooked |
92 | }; |
93 | }; |
94 | |
95 | const mapDispatchToProps = dispatch => { |
96 | return { |
97 | doneBooking: () => dispatch(doneBooking()), |
98 | onSelectedDay: id => dispatch(onSelectedDay(id)), |
99 | iconClick: () => dispatch(iconClick()), |
100 | bookingDetails: (details, updatesGame) => dispatch({ type: "BOOKINGS", details, updatesGame }), |
101 | }; |
102 | }; |
103 | |
104 | export default connect( |
105 | mapStateToProps, |
106 | mapDispatchToProps |
107 | )(Booking); |
108 |
book.test.js
· 9.1 KiB · JavaScript
Raw
test/book.test.js
import React, { Component } from "react";
import { Booking } from "../pages/book";
import { shallow, mount } from "enzyme";
import configureStore from "redux-mock-store";
import { configure } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
import BasketBall from "../images/basket_ball.jpeg";
import VolleyBall from "../images/volleyBall.jpeg";
import cricket from "../images/cricket_bat.jpg";
import FootBall from "../images/football.jpeg";
import {
bookSlot1,
bookSlot2,
bookSlot3,
bookSlot4
} from "../Component/slot_data";
import DayPicker from "react-day-picker";
configure({ adapter: new Adapter() });
const mockStore = configureStore([]);
describe("Book page", () => {
const historyMock = { push: jest.fn() };
const mockfn1 = jest.fn();
const mockfn2 = jest.fn();
window.alert = jest.fn();
let store;
let component;
let error;
let Dates;
let Closed;
beforeEach(() => {
const Games1 = [
{ id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 },
{ id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 },
{ id: 2, src: cricket, name: "Cricket", slots: bookSlot3 },
{ id: 3, src: FootBall, name: "FootBall", slots: bookSlot4 }
]
const selectedGame1 = [
{ id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 }
]
const selectedDate1 = new Date(
new Date().getFullYear(),
new Date().getMonth(),
new Date().getDate() + 1
)
const slotBooked1 = undefined
component = shallow(
<Booking
game={Games1}
selectedGame={selectedGame1}
selectedDate={selectedDate1}
slotBooked={slotBooked1}
onSelectedDay={mockfn1}
bookingDetails={mockfn1}
iconClick={mockfn1}
history={historyMock}
doneBooking={mockfn1}
/>
)
});
it("Book Content", () => {
const Date_display =
new Date().getDate() + 1 + "/" + (new Date().getMonth() + 1) + "/" + new Date().getFullYear();
expect(component.find("header").length).toBe(1);
expect(component.find("header").childAt(0).length).toBe(1);
expect(component.find("header").find("p").length).toBe(1);
expect(component.find("header").text()).toBe(
"Play Zone:Slot Date:" + Date_display
);
expect(component.find(".Card").length).toBe(1);
expect(component.find("#book_button")).toBeTruthy();
component
.find("header")
.find("img")
.simulate("click");
expect(historyMock.push.mock.calls[0]).toEqual(["/"]);
expect(component.find("#date").find(DayPicker).length).toBe(1);
});
it("input fields", () => {
expect(component.find("#contact").length).toBe(2);
component
.find("#contact")
.at(0)
.simulate("change", { target: { name: "name", value: "anu" } });
expect(component.state().name).toEqual("anu");
component
.find("#contact")
.at(1)
.simulate("change", { target: { name: "contact", value: "9890900001" } });
expect(component.state().contact).toEqual("9890900001");
component
.find("#contact")
.at(0)
.simulate("change", { target: { name: "name", value: "" } });
expect(component.state().name).toEqual("");
component
.find("#contact")
.at(1)
.simulate("change", { target: { name: "contact", value: "" } });
expect(component.state().contact).toEqual("");
});
it("err msg: select your slot", () => {
component.find("#book_button").simulate("Click");
expect(component.state().errorStmt).toEqual("Select your slot!!!");
component
.find("#contact")
.at(0)
.simulate("change", { target: { name: "name", value: "anu" } });
component
.find("#contact")
.at(1)
.simulate("change", { target: { name: "contact", value: "9890900001" } });
component.find("#book_button").simulate("Click");
expect(component.state().errorStmt).toEqual("Select your slot!!!");
});
it("err msg check your field", () => {
const Games2 = [
{ id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 },
{ id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 },
{ id: 2, src: cricket, name: "Cricket", slots: bookSlot3 },
{ id: 3, src: FootBall, name: "FootBall", slots: bookSlot4 }
]
const selectedGame2 =
{
id: 1, src: VolleyBall, name: "VolleyBall", slots: [
{ id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-primary" },
{ id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" }
]
}
const selectedDate2 = new Date(
new Date().getFullYear(),
new Date().getMonth(),
new Date().getDate() + 1
)
const slotBooked2 = [
{ id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" }
]
const wrapper = shallow(
<Booking
game={Games2}
selectedGame={selectedGame2}
selectedDate={selectedDate2}
slotBooked={slotBooked2}
onSelectedDay={mockfn1}
bookingDetails={mockfn2}
iconClick={mockfn1}
history={historyMock}
doneBooking={mockfn1}
/>
)
wrapper.find("#book_button").simulate("Click");
expect(wrapper.state().errorStmt).toEqual("Invalid Input!!!");
wrapper
.find("#contact")
.at(0)
.simulate("change", { target: { name: "name", value: "anu" } });
wrapper.find("#book_button").simulate("Click");
expect(wrapper.state().errorStmt).toEqual("Invalid Input!!!");
wrapper
.find("#contact")
.at(1)
.simulate("change", { target: { name: "contact", value: "9890" } });
wrapper.find("#book_button").simulate("Click");
expect(wrapper.state().errorStmt).toEqual("Invalid Input!!!");
wrapper
.find("#contact")
.at(0)
.simulate("change", { target: { name: "name", value: "987" } });
wrapper
.find("#contact")
.at(0)
.simulate("change", { target: { name: "contact", value: "9890980908" } });
wrapper.find("#book_button").simulate("Click");
expect(wrapper.state().errorStmt).toEqual("Invalid Input!!!");
wrapper
.find("#contact")
.at(0)
.simulate("change", { target: { name: "name", value: "anu" } });
wrapper
.find("#contact")
.at(1)
.simulate("change", { target: { name: "contact", value: "9890980908" } });
wrapper.find("#book_button").simulate("Click");
expect(wrapper.state().errorStmt).toEqual("");
expect(mockfn1).toHaveBeenCalled();
expect(window.alert).toHaveBeenCalled();
});
it("Display slot", () => {
expect(component.find("Connect(Slots)").length).toBe(1);
});
it("Booking not opened", () => {
const Games3 = [
{ id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 },
{ id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 },
{ id: 2, src: cricket, name: "Cricket", slots: bookSlot3 },
{ id: 3, src: FootBall, name: "FootBall", slots: bookSlot4 }
]
const selectedGame3 = [
{ id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 }
]
const selectedDate3 = new Date(
new Date().getFullYear(),
new Date().getMonth(),
new Date().getDate() + 2
)
const slotBooked3 = undefined
const wrapper = shallow(
<Booking
game={Games3}
selectedGame={selectedGame3}
selectedDate={selectedDate3}
slotBooked={slotBooked3}
onSelectedDay={mockfn1}
bookingDetails={mockfn1}
iconClick={mockfn1}
history={historyMock}
doneBooking={mockfn1}
/>)
expect(wrapper.find("#not_opened").text()).toBe(
"Booking is not opened yet"
);
expect(wrapper.find("Slots").length).toBe(0);
expect(component.find("#date").find(DayPicker).length).toBe(1);
expect(wrapper.find("#book_button").length).toBe(0);
});
it("Booking Closed", () => {
const Games1 = [
{ id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 },
{ id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 },
{ id: 2, src: cricket, name: "Cricket", slots: bookSlot3 },
{ id: 3, src: FootBall, name: "FootBall", slots: bookSlot4 }
]
const selectedGame1 = [
{ id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 }
]
const selectedDate1 = new Date(
new Date().getFullYear(),
new Date().getMonth(),
new Date().getDate()
)
const slotBooked1 = undefined
const Date_display = new Date().getDate() + 1 + "/" + (new Date().getMonth() + 1) + "/" + new Date().getFullYear();
const wrapper = shallow(
<Booking
game={Games1}
selectedGame={selectedGame1}
selectedDate={selectedDate1}
slotBooked={slotBooked1}
onSelectedDay={mockfn1}
bookingDetails={mockfn1}
iconClick={mockfn1}
history={historyMock}
doneBooking={mockfn1}
/>
)
expect(
wrapper
.find("#not_opened")
.render()
.text()
).toBe("Booking has been closed. Book your slot for" + Date_display);
expect(wrapper.find("Slots").length).toBe(0);
expect(wrapper.find("#date").find(DayPicker).length).toBe(1);
expect(wrapper.find("#book_button").length).toBe(0);
});
});
1 | test/book.test.js |
2 | |
3 | import React, { Component } from "react"; |
4 | import { Booking } from "../pages/book"; |
5 | import { shallow, mount } from "enzyme"; |
6 | import configureStore from "redux-mock-store"; |
7 | import { configure } from "enzyme"; |
8 | import Adapter from "enzyme-adapter-react-16"; |
9 | import BasketBall from "../images/basket_ball.jpeg"; |
10 | import VolleyBall from "../images/volleyBall.jpeg"; |
11 | import cricket from "../images/cricket_bat.jpg"; |
12 | import FootBall from "../images/football.jpeg"; |
13 | import { |
14 | bookSlot1, |
15 | bookSlot2, |
16 | bookSlot3, |
17 | bookSlot4 |
18 | } from "../Component/slot_data"; |
19 | import DayPicker from "react-day-picker"; |
20 | |
21 | configure({ adapter: new Adapter() }); |
22 | |
23 | const mockStore = configureStore([]); |
24 | describe("Book page", () => { |
25 | const historyMock = { push: jest.fn() }; |
26 | const mockfn1 = jest.fn(); |
27 | const mockfn2 = jest.fn(); |
28 | window.alert = jest.fn(); |
29 | let store; |
30 | let component; |
31 | let error; |
32 | let Dates; |
33 | let Closed; |
34 | |
35 | beforeEach(() => { |
36 | const Games1 = [ |
37 | { id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 }, |
38 | { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 }, |
39 | { id: 2, src: cricket, name: "Cricket", slots: bookSlot3 }, |
40 | { id: 3, src: FootBall, name: "FootBall", slots: bookSlot4 } |
41 | ] |
42 | const selectedGame1 = [ |
43 | { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 } |
44 | ] |
45 | const selectedDate1 = new Date( |
46 | new Date().getFullYear(), |
47 | new Date().getMonth(), |
48 | new Date().getDate() + 1 |
49 | ) |
50 | const slotBooked1 = undefined |
51 | component = shallow( |
52 | <Booking |
53 | game={Games1} |
54 | selectedGame={selectedGame1} |
55 | selectedDate={selectedDate1} |
56 | slotBooked={slotBooked1} |
57 | onSelectedDay={mockfn1} |
58 | bookingDetails={mockfn1} |
59 | iconClick={mockfn1} |
60 | history={historyMock} |
61 | doneBooking={mockfn1} |
62 | /> |
63 | ) |
64 | |
65 | }); |
66 | it("Book Content", () => { |
67 | const Date_display = |
68 | new Date().getDate() + 1 + "/" + (new Date().getMonth() + 1) + "/" + new Date().getFullYear(); |
69 | expect(component.find("header").length).toBe(1); |
70 | expect(component.find("header").childAt(0).length).toBe(1); |
71 | expect(component.find("header").find("p").length).toBe(1); |
72 | expect(component.find("header").text()).toBe( |
73 | "Play Zone:Slot Date:" + Date_display |
74 | ); |
75 | expect(component.find(".Card").length).toBe(1); |
76 | expect(component.find("#book_button")).toBeTruthy(); |
77 | component |
78 | .find("header") |
79 | .find("img") |
80 | .simulate("click"); |
81 | expect(historyMock.push.mock.calls[0]).toEqual(["/"]); |
82 | expect(component.find("#date").find(DayPicker).length).toBe(1); |
83 | }); |
84 | it("input fields", () => { |
85 | expect(component.find("#contact").length).toBe(2); |
86 | component |
87 | .find("#contact") |
88 | .at(0) |
89 | .simulate("change", { target: { name: "name", value: "anu" } }); |
90 | expect(component.state().name).toEqual("anu"); |
91 | component |
92 | .find("#contact") |
93 | .at(1) |
94 | .simulate("change", { target: { name: "contact", value: "9890900001" } }); |
95 | expect(component.state().contact).toEqual("9890900001"); |
96 | component |
97 | .find("#contact") |
98 | .at(0) |
99 | .simulate("change", { target: { name: "name", value: "" } }); |
100 | expect(component.state().name).toEqual(""); |
101 | component |
102 | .find("#contact") |
103 | .at(1) |
104 | .simulate("change", { target: { name: "contact", value: "" } }); |
105 | expect(component.state().contact).toEqual(""); |
106 | }); |
107 | it("err msg: select your slot", () => { |
108 | component.find("#book_button").simulate("Click"); |
109 | expect(component.state().errorStmt).toEqual("Select your slot!!!"); |
110 | component |
111 | .find("#contact") |
112 | .at(0) |
113 | .simulate("change", { target: { name: "name", value: "anu" } }); |
114 | component |
115 | .find("#contact") |
116 | .at(1) |
117 | .simulate("change", { target: { name: "contact", value: "9890900001" } }); |
118 | component.find("#book_button").simulate("Click"); |
119 | expect(component.state().errorStmt).toEqual("Select your slot!!!"); |
120 | }); |
121 | it("err msg check your field", () => { |
122 | const Games2 = [ |
123 | { id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 }, |
124 | { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 }, |
125 | { id: 2, src: cricket, name: "Cricket", slots: bookSlot3 }, |
126 | { id: 3, src: FootBall, name: "FootBall", slots: bookSlot4 } |
127 | ] |
128 | const selectedGame2 = |
129 | { |
130 | id: 1, src: VolleyBall, name: "VolleyBall", slots: [ |
131 | { id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-primary" }, |
132 | { id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" } |
133 | ] |
134 | } |
135 | |
136 | const selectedDate2 = new Date( |
137 | new Date().getFullYear(), |
138 | new Date().getMonth(), |
139 | new Date().getDate() + 1 |
140 | ) |
141 | const slotBooked2 = [ |
142 | { id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" } |
143 | ] |
144 | const wrapper = shallow( |
145 | <Booking |
146 | game={Games2} |
147 | selectedGame={selectedGame2} |
148 | selectedDate={selectedDate2} |
149 | slotBooked={slotBooked2} |
150 | onSelectedDay={mockfn1} |
151 | bookingDetails={mockfn2} |
152 | iconClick={mockfn1} |
153 | history={historyMock} |
154 | doneBooking={mockfn1} |
155 | /> |
156 | ) |
157 | |
158 | wrapper.find("#book_button").simulate("Click"); |
159 | expect(wrapper.state().errorStmt).toEqual("Invalid Input!!!"); |
160 | wrapper |
161 | .find("#contact") |
162 | .at(0) |
163 | .simulate("change", { target: { name: "name", value: "anu" } }); |
164 | wrapper.find("#book_button").simulate("Click"); |
165 | expect(wrapper.state().errorStmt).toEqual("Invalid Input!!!"); |
166 | wrapper |
167 | .find("#contact") |
168 | .at(1) |
169 | .simulate("change", { target: { name: "contact", value: "9890" } }); |
170 | wrapper.find("#book_button").simulate("Click"); |
171 | expect(wrapper.state().errorStmt).toEqual("Invalid Input!!!"); |
172 | wrapper |
173 | .find("#contact") |
174 | .at(0) |
175 | .simulate("change", { target: { name: "name", value: "987" } }); |
176 | wrapper |
177 | .find("#contact") |
178 | .at(0) |
179 | .simulate("change", { target: { name: "contact", value: "9890980908" } }); |
180 | wrapper.find("#book_button").simulate("Click"); |
181 | expect(wrapper.state().errorStmt).toEqual("Invalid Input!!!"); |
182 | wrapper |
183 | .find("#contact") |
184 | .at(0) |
185 | .simulate("change", { target: { name: "name", value: "anu" } }); |
186 | wrapper |
187 | .find("#contact") |
188 | .at(1) |
189 | .simulate("change", { target: { name: "contact", value: "9890980908" } }); |
190 | wrapper.find("#book_button").simulate("Click"); |
191 | expect(wrapper.state().errorStmt).toEqual(""); |
192 | expect(mockfn1).toHaveBeenCalled(); |
193 | expect(window.alert).toHaveBeenCalled(); |
194 | }); |
195 | |
196 | it("Display slot", () => { |
197 | expect(component.find("Connect(Slots)").length).toBe(1); |
198 | }); |
199 | it("Booking not opened", () => { |
200 | const Games3 = [ |
201 | { id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 }, |
202 | { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 }, |
203 | { id: 2, src: cricket, name: "Cricket", slots: bookSlot3 }, |
204 | { id: 3, src: FootBall, name: "FootBall", slots: bookSlot4 } |
205 | ] |
206 | const selectedGame3 = [ |
207 | { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 } |
208 | ] |
209 | const selectedDate3 = new Date( |
210 | new Date().getFullYear(), |
211 | new Date().getMonth(), |
212 | new Date().getDate() + 2 |
213 | ) |
214 | const slotBooked3 = undefined |
215 | const wrapper = shallow( |
216 | <Booking |
217 | game={Games3} |
218 | selectedGame={selectedGame3} |
219 | selectedDate={selectedDate3} |
220 | slotBooked={slotBooked3} |
221 | onSelectedDay={mockfn1} |
222 | bookingDetails={mockfn1} |
223 | iconClick={mockfn1} |
224 | history={historyMock} |
225 | doneBooking={mockfn1} |
226 | />) |
227 | expect(wrapper.find("#not_opened").text()).toBe( |
228 | "Booking is not opened yet" |
229 | ); |
230 | expect(wrapper.find("Slots").length).toBe(0); |
231 | expect(component.find("#date").find(DayPicker).length).toBe(1); |
232 | expect(wrapper.find("#book_button").length).toBe(0); |
233 | }); |
234 | it("Booking Closed", () => { |
235 | const Games1 = [ |
236 | { id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 }, |
237 | { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 }, |
238 | { id: 2, src: cricket, name: "Cricket", slots: bookSlot3 }, |
239 | { id: 3, src: FootBall, name: "FootBall", slots: bookSlot4 } |
240 | ] |
241 | const selectedGame1 = [ |
242 | { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 } |
243 | ] |
244 | const selectedDate1 = new Date( |
245 | new Date().getFullYear(), |
246 | new Date().getMonth(), |
247 | new Date().getDate() |
248 | ) |
249 | const slotBooked1 = undefined |
250 | const Date_display = new Date().getDate() + 1 + "/" + (new Date().getMonth() + 1) + "/" + new Date().getFullYear(); |
251 | const wrapper = shallow( |
252 | <Booking |
253 | game={Games1} |
254 | selectedGame={selectedGame1} |
255 | selectedDate={selectedDate1} |
256 | slotBooked={slotBooked1} |
257 | onSelectedDay={mockfn1} |
258 | bookingDetails={mockfn1} |
259 | iconClick={mockfn1} |
260 | history={historyMock} |
261 | doneBooking={mockfn1} |
262 | /> |
263 | ) |
264 | |
265 | expect( |
266 | wrapper |
267 | .find("#not_opened") |
268 | .render() |
269 | .text() |
270 | ).toBe("Booking has been closed. Book your slot for" + Date_display); |
271 | expect(wrapper.find("Slots").length).toBe(0); |
272 | expect(wrapper.find("#date").find(DayPicker).length).toBe(1); |
273 | expect(wrapper.find("#book_button").length).toBe(0); |
274 | }); |
275 | }); |
276 |
home.js
· 1.5 KiB · JavaScript
Raw
pages/home.js
import React, { Component } from "react";
import "../App.css";
import "bootstrap/dist/css/bootstrap.css";
import { selectGame } from "../Action/action";
import { connect } from "react-redux";
export class Games extends Component {
handlebook = i => {
};
handleSearch = () => {
};
render() {
// Template to display each game
// <div className="Card" key={game.id}>
// <ul>
// <li>
// <img hieght="300px" width="200px"></img>
// </li>
// <li></li>
// <li>
// <button
// className="btn btn-dark "
// >
// Book Now
// </button>
// </li>
// </ul>
// </div>
return (
<div className="Home">
<header>
{/* code goes here to display the title and and an image */}
</header>
<center>
{/* code goes here to loop the each game */}
</center>
<center>
<div>
<button
className=" btn-lg btn btn-dark m-2"
>
</button>
</div>
</center>
</div>
);
}
}
const mapStateToProps = state => {
return {
Games: state.Games
};
};
const mapDispatchToProps = dispatch => {
return {
postDate: (date) => dispatch({ type: "TODAY_DATE", date }),
selectGame: id => dispatch(selectGame(id)),
getGameAndBooking: () => dispatch({ type: "GAME_BOOKING" })
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(Games);
1 | pages/home.js |
2 | |
3 | import React, { Component } from "react"; |
4 | import "../App.css"; |
5 | import "bootstrap/dist/css/bootstrap.css"; |
6 | import { selectGame } from "../Action/action"; |
7 | import { connect } from "react-redux"; |
8 | |
9 | export class Games extends Component { |
10 | |
11 | handlebook = i => { |
12 | |
13 | }; |
14 | |
15 | handleSearch = () => { |
16 | |
17 | }; |
18 | |
19 | render() { |
20 | |
21 | // Template to display each game |
22 | |
23 | // <div className="Card" key={game.id}> |
24 | // <ul> |
25 | // <li> |
26 | // <img hieght="300px" width="200px"></img> |
27 | // </li> |
28 | // <li></li> |
29 | // <li> |
30 | // <button |
31 | // className="btn btn-dark " |
32 | // > |
33 | // Book Now |
34 | // </button> |
35 | // </li> |
36 | // </ul> |
37 | // </div> |
38 | |
39 | return ( |
40 | <div className="Home"> |
41 | <header> |
42 | {/* code goes here to display the title and and an image */} |
43 | </header> |
44 | <center> |
45 | {/* code goes here to loop the each game */} |
46 | </center> |
47 | <center> |
48 | <div> |
49 | <button |
50 | className=" btn-lg btn btn-dark m-2" |
51 | > |
52 | |
53 | </button> |
54 | </div> |
55 | </center> |
56 | </div> |
57 | ); |
58 | } |
59 | } |
60 | const mapStateToProps = state => { |
61 | return { |
62 | Games: state.Games |
63 | }; |
64 | }; |
65 | const mapDispatchToProps = dispatch => { |
66 | return { |
67 | |
68 | postDate: (date) => dispatch({ type: "TODAY_DATE", date }), |
69 | selectGame: id => dispatch(selectGame(id)), |
70 | getGameAndBooking: () => dispatch({ type: "GAME_BOOKING" }) |
71 | }; |
72 | }; |
73 | |
74 | export default connect( |
75 | mapStateToProps, |
76 | mapDispatchToProps |
77 | )(Games); |
78 |
home.test.js
· 2.8 KiB · JavaScript
Raw
home.test.js
import React from "react";
import { Games } from "../pages/home";
import { shallow } from "enzyme";
import configureStore from "redux-mock-store";
import { configure } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
import BasketBall from "../images/basket_ball.jpeg";
import VolleyBall from "../images/volleyBall.jpeg";
import cricket from "../images/cricket_bat.jpg";
import FootBall from "../images/football.jpeg";
import {
bookSlot1,
bookSlot2,
bookSlot3,
bookSlot4
} from "../Component/slot_data";
configure({ adapter: new Adapter() });
const mockStore = configureStore([]);
describe("Home component", () => {
const historyMock = { push: jest.fn() };
const mockfn1 = jest.fn();
const mockfn2 = jest.fn();
const mockfn3 = jest.fn();
let store;
let component;
afterEach(() => {
jest.clearAllMocks();
})
beforeEach(() => {
const Games1 = [
{ id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 },
{ id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 },
{ id: 2, src: cricket, name: "Cricket", slots: bookSlot3 },
{ id: 3, src: FootBall, name: "FootBall", slots: bookSlot4 }
]
component = shallow(
<Games
Games={Games1}
selectGame={mockfn3}
getGameAndBooking={mockfn1}
history={historyMock}
postDate={mockfn2}
/>
)
});
it("DidMount", () => {
expect(mockfn1).toHaveBeenCalledTimes(1);
expect(mockfn2).toHaveBeenCalledTimes(1);
})
it("play zone content", () => {
expect(component.find("header").length).toBe(1);
expect(component.find("header").text()).toEqual("Play Zone ");
expect(component.find(".Card").length).toBe(4);
const align = component
.find("center")
.at(1)
.find("div")
.find("button");
expect(align.render().text()).toBe("Check your booking");
expect(component.find("header").childAt(0).length).toBe(1);
});
it("card content", () => {
const Cards = component.find(".Card");
const Product = Cards.find("ul").map(child => child.text());
expect(Product).toEqual([
"BasketBallBook Now",
"VolleyBallBook Now",
"CricketBook Now",
"FootBallBook Now"
]);
});
it("BookNow Click", () => {
const spy = jest.spyOn(component.instance(), "handlebook");
const BookNow_Btn = component
.find("center")
.at(0)
.find("div")
.find("button")
.at(1);
BookNow_Btn.simulate("click");
expect(spy).toHaveBeenCalled();
expect(mockfn3).toHaveBeenCalledTimes(1);
});
it("On Clicking Book Now", () => {
const spy = jest.spyOn(component.instance(), "handleSearch");
const check_btn = component
.find("center")
.at(1)
.find("div")
.find("button");
check_btn.simulate("click");
expect(spy).toHaveBeenCalled();
});
});
1 | home.test.js |
2 | |
3 | import React from "react"; |
4 | import { Games } from "../pages/home"; |
5 | import { shallow } from "enzyme"; |
6 | import configureStore from "redux-mock-store"; |
7 | import { configure } from "enzyme"; |
8 | import Adapter from "enzyme-adapter-react-16"; |
9 | import BasketBall from "../images/basket_ball.jpeg"; |
10 | import VolleyBall from "../images/volleyBall.jpeg"; |
11 | import cricket from "../images/cricket_bat.jpg"; |
12 | import FootBall from "../images/football.jpeg"; |
13 | import { |
14 | bookSlot1, |
15 | bookSlot2, |
16 | bookSlot3, |
17 | bookSlot4 |
18 | } from "../Component/slot_data"; |
19 | |
20 | configure({ adapter: new Adapter() }); |
21 | |
22 | const mockStore = configureStore([]); |
23 | describe("Home component", () => { |
24 | const historyMock = { push: jest.fn() }; |
25 | const mockfn1 = jest.fn(); |
26 | const mockfn2 = jest.fn(); |
27 | const mockfn3 = jest.fn(); |
28 | let store; |
29 | let component; |
30 | afterEach(() => { |
31 | jest.clearAllMocks(); |
32 | }) |
33 | beforeEach(() => { |
34 | const Games1 = [ |
35 | { id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 }, |
36 | { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 }, |
37 | { id: 2, src: cricket, name: "Cricket", slots: bookSlot3 }, |
38 | { id: 3, src: FootBall, name: "FootBall", slots: bookSlot4 } |
39 | ] |
40 | component = shallow( |
41 | <Games |
42 | Games={Games1} |
43 | selectGame={mockfn3} |
44 | getGameAndBooking={mockfn1} |
45 | history={historyMock} |
46 | postDate={mockfn2} |
47 | /> |
48 | ) |
49 | |
50 | }); |
51 | it("DidMount", () => { |
52 | expect(mockfn1).toHaveBeenCalledTimes(1); |
53 | expect(mockfn2).toHaveBeenCalledTimes(1); |
54 | }) |
55 | it("play zone content", () => { |
56 | expect(component.find("header").length).toBe(1); |
57 | expect(component.find("header").text()).toEqual("Play Zone "); |
58 | expect(component.find(".Card").length).toBe(4); |
59 | const align = component |
60 | .find("center") |
61 | .at(1) |
62 | .find("div") |
63 | .find("button"); |
64 | expect(align.render().text()).toBe("Check your booking"); |
65 | expect(component.find("header").childAt(0).length).toBe(1); |
66 | }); |
67 | it("card content", () => { |
68 | const Cards = component.find(".Card"); |
69 | const Product = Cards.find("ul").map(child => child.text()); |
70 | expect(Product).toEqual([ |
71 | "BasketBallBook Now", |
72 | "VolleyBallBook Now", |
73 | "CricketBook Now", |
74 | "FootBallBook Now" |
75 | ]); |
76 | }); |
77 | it("BookNow Click", () => { |
78 | const spy = jest.spyOn(component.instance(), "handlebook"); |
79 | const BookNow_Btn = component |
80 | .find("center") |
81 | .at(0) |
82 | .find("div") |
83 | .find("button") |
84 | .at(1); |
85 | BookNow_Btn.simulate("click"); |
86 | expect(spy).toHaveBeenCalled(); |
87 | expect(mockfn3).toHaveBeenCalledTimes(1); |
88 | }); |
89 | it("On Clicking Book Now", () => { |
90 | const spy = jest.spyOn(component.instance(), "handleSearch"); |
91 | const check_btn = component |
92 | .find("center") |
93 | .at(1) |
94 | .find("div") |
95 | .find("button"); |
96 | check_btn.simulate("click"); |
97 | expect(spy).toHaveBeenCalled(); |
98 | }); |
99 | }); |
100 | |
101 |
index.js
· 486 B · JavaScript
Raw
sagas/index.js
import { takeEvery, put, call } from "redux-saga/effects";
import axios from "axios";
function* bookingAsync(action) {
}
function* getGameAndBookingAsync() {
}
function* postTodayTime(action) {
}
export function* watchBooking() {
yield takeEvery("BOOKINGS", bookingAsync);
}
export function* watchUpdateGame() {
yield takeEvery("GAME_BOOKING", getGameAndBookingAsync);
}
export function* watchPostTodayTime() {
yield takeEvery("TODAY_DATE", postTodayTime);
}
1 | sagas/index.js |
2 | |
3 | import { takeEvery, put, call } from "redux-saga/effects"; |
4 | import axios from "axios"; |
5 | |
6 | function* bookingAsync(action) { |
7 | |
8 | } |
9 | function* getGameAndBookingAsync() { |
10 | |
11 | } |
12 | function* postTodayTime(action) { |
13 | |
14 | } |
15 | |
16 | export function* watchBooking() { |
17 | yield takeEvery("BOOKINGS", bookingAsync); |
18 | } |
19 | export function* watchUpdateGame() { |
20 | yield takeEvery("GAME_BOOKING", getGameAndBookingAsync); |
21 | } |
22 | export function* watchPostTodayTime() { |
23 | yield takeEvery("TODAY_DATE", postTodayTime); |
24 | } |
25 |
reducer.js
· 421 B · JavaScript
Raw
const initState = {
};
const bookNowReducer = (state = initState, action) => {
switch (action.type) {
case "DONE_BOOKING": {
}
case "UPDATE_BOOKING": {
}
case "SELECT_GAME": {
}
case "ICON_CLICK": {
}
case "ON_SELECTED_DAY": {
}
case "ON_SELECT_SLOT": {
}
case "CHECK_BOOKING": {
}
default:
return state;
}
};
export default bookNowReducer;
1 | const initState = { |
2 | |
3 | }; |
4 | |
5 | const bookNowReducer = (state = initState, action) => { |
6 | switch (action.type) { |
7 | case "DONE_BOOKING": { |
8 | |
9 | } |
10 | case "UPDATE_BOOKING": { |
11 | |
12 | } |
13 | case "SELECT_GAME": { |
14 | |
15 | } |
16 | case "ICON_CLICK": { |
17 | |
18 | } |
19 | case "ON_SELECTED_DAY": { |
20 | |
21 | } |
22 | case "ON_SELECT_SLOT": { |
23 | |
24 | } |
25 | |
26 | case "CHECK_BOOKING": { |
27 | |
28 | } |
29 | default: |
30 | return state; |
31 | } |
32 | }; |
33 | export default bookNowReducer; |
34 |
reducer.test.js
· 8.9 KiB · JavaScript
Raw
test/reducer.test.js
import bookNowReducer from "../Reducer/reducer";
import BasketBall from "../images/basket_ball.jpeg";
import VolleyBall from "../images/volleyBall.jpeg";
import { bookSlot1, bookSlot2 } from "../Component/slot_data";
describe("testing cart reducer", () => {
const initState = {
Games: [],
selectedGame: [],
selectedDate: new Date(
new Date().getFullYear(),
new Date().getMonth(),
new Date().getDate() + 1
),
slotBooked: undefined,
details: [],
bookingCheck: []
};
it("initial state check", () => {
expect(bookNowReducer(undefined, {})).toEqual(initState);
});
it("UPDATE_BOOKING", () => {
const state = {
Games: [],
details: []
}
expect(bookNowReducer(state, {
type: "UPDATE_BOOKING",
GameAndSlot: [
{ id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 },
{ id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 }
],
BookingDetail: [
{
bookingId: "14440074", contact: "9876443111", game: "BasketBall", name: "Roger", slotDate: "6/12/2020",
slot: { id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" }
},
{
bookingId: "92303869", contact: "9867844311", game: "FootBall", name: "shelly", slotDate: "6/12/2020",
slot: { id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" }
}
]
})).toEqual({
Games: [
{ id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 },
{ id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 }
],
details: [
{
bookingId: "14440074", contact: "9876443111", game: "BasketBall", name: "Roger", slotDate: "6/12/2020",
slot: { id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" }
},
{
bookingId: "92303869", contact: "9867844311", game: "FootBall", name: "shelly", slotDate: "6/12/2020",
slot: { id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" }
}
]
});
});
it("select game(onBook)", () => {
const state = {
Games: [
{ id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 },
{ id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 }
],
selectedGame: []
};
expect(bookNowReducer(state, { type: "SELECT_GAME", id: 1 })).toEqual({
Games: [
{ id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 },
{ id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 }
],
selectedGame: { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 }
});
const next_state = {
Games: [
{ id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 },
{
id: 1, src: VolleyBall, name: "VolleyBall", slots: [
{ id: 1, startTime: "09.00 A.M", endTime: "10.00 A.M", slotStatus: "btn btn-primary" },
{ id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-success" },
{ id: 3, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-danger" }
]
}
],
selectedGame: []
};
expect(bookNowReducer(next_state, { type: "SELECT_GAME", id: 1 })).toEqual({
Games: [
{ id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 },
{
id: 1, src: VolleyBall, name: "VolleyBall",
slots: [
{ id: 1, startTime: "09.00 A.M", endTime: "10.00 A.M", slotStatus: "btn btn-success" },
{ id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-success" },
{ id: 3, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-danger" }
]
}
],
selectedGame: {
id: 1, src: VolleyBall, name: "VolleyBall",
slots: [
{ id: 1, startTime: "09.00 A.M", endTime: "10.00 A.M", slotStatus: "btn btn-success" },
{ id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-success" },
{ id: 3, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-danger" }
]
}
});
});
// .....
it("onShow", () => {
const state = {
selectedDate: new Date(
new Date().getFullYear(),
new Date().getMonth(),
new Date().getDate() + 1
)
};
expect(
bookNowReducer(state, {
type: "ON_SELECTED_DAY",
Day: "Wed Mar 11 2020 12:00:00 GMT+0530 (India Standard Time)"
})
).toEqual({
selectedDate: "Wed Mar 11 2020 12:00:00 GMT+0530 (India Standard Time)"
});
});
it("on select slot", () => {
const state = {
selectedGame: { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 },
slotBooked: undefined
};
expect(bookNowReducer(state, { type: "ON_SELECT_SLOT", id: 2 })).toEqual({
selectedGame: { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 },
slotBooked: { id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-primary" }
});
expect(bookNowReducer(state, { type: "ON_SELECT_SLOT", id: 6 })).toEqual({
selectedGame: { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 },
slotBooked:
{ id: 6, startTime: "02.00 P.M", endTime: "03.00 P.M", slotStatus: "btn btn-primary" }
});
const Nextstate = {
selectedGame: {
id: 1, src: VolleyBall, name: "VolleyBall",
slots: [
{ id: 1, startTime: "09.00 A.M", endTime: "10.00 A.M", slotStatus: "btn btn-success" },
{ id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-danger" }
]
},
slotBooked: undefined
};
expect(bookNowReducer(Nextstate, { type: "ON_SELECT_SLOT", id: 2 })).toEqual({
selectedGame: {
id: 1, src: VolleyBall, name: "VolleyBall",
slots: [
{ id: 1, startTime: "09.00 A.M", endTime: "10.00 A.M", slotStatus: "btn btn-success" },
{ id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-danger" }
]
},
slotBooked: undefined
});
});
it("DONE_BOOKING", () => {
const state = {
selectedGame: {
id: 1, src: VolleyBall, name: "VolleyBall",
slots: [
{ id: 1, startTime: "09.00 A.M", endTime: "10.00 A.M", slotStatus: "btn btn-success" },
{ id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-primary" }
]
},
slotBooked: { id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-primary" }
};
expect(bookNowReducer(state, { type: "DONE_BOOKING" })).toEqual({
selectedGame: {
id: 1, src: VolleyBall, name: "VolleyBall",
slots: [
{ id: 1, startTime: "09.00 A.M", endTime: "10.00 A.M", slotStatus: "btn btn-success" },
{ id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-danger" }
]
},
slotBooked: undefined
})
})
it("doneBooking", () => {
const state = {
slotBooked: { id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-primary" }
};
expect(bookNowReducer(state, { type: "ICON_CLICK", id: 2 })).toEqual({
slotBooked: undefined
})
})
it("check Booking", () => {
const state = {
bookingCheck: [],
details: [
{
bookingId: "14440074", contact: "9876443111", game: "BasketBall", name: "Roger", slotDate: "6/12/2020",
slot:
{ id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" }
},
{
bookingId: "92303869",
contact: "9867844311",
game: "FootBall",
name: "shelly",
slotDate: "6/12/2020",
slot: { id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" }
}
]
};
expect(
bookNowReducer(state, { type: "CHECK_BOOKING", payload: "9230" })
).toEqual({
bookingCheck: [
{
bookingId: "92303869",
contact: "9867844311",
game: "FootBall",
name: "shelly",
slotDate: "6/12/2020",
slot:
{ id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" }
}
],
details: [
{
bookingId: "14440074",
contact: "9876443111",
game: "BasketBall",
name: "Roger",
slotDate: "6/12/2020",
slot:
{ id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" }
},
{
bookingId: "92303869",
contact: "9867844311",
game: "FootBall",
name: "shelly",
slotDate: "6/12/2020",
slot:
{ id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" }
}
]
});
});
});
1 | test/reducer.test.js |
2 | |
3 | import bookNowReducer from "../Reducer/reducer"; |
4 | import BasketBall from "../images/basket_ball.jpeg"; |
5 | import VolleyBall from "../images/volleyBall.jpeg"; |
6 | import { bookSlot1, bookSlot2 } from "../Component/slot_data"; |
7 | |
8 | describe("testing cart reducer", () => { |
9 | const initState = { |
10 | Games: [], |
11 | selectedGame: [], |
12 | selectedDate: new Date( |
13 | new Date().getFullYear(), |
14 | new Date().getMonth(), |
15 | new Date().getDate() + 1 |
16 | ), |
17 | |
18 | slotBooked: undefined, |
19 | details: [], |
20 | bookingCheck: [] |
21 | }; |
22 | it("initial state check", () => { |
23 | expect(bookNowReducer(undefined, {})).toEqual(initState); |
24 | }); |
25 | it("UPDATE_BOOKING", () => { |
26 | const state = { |
27 | Games: [], |
28 | details: [] |
29 | } |
30 | expect(bookNowReducer(state, { |
31 | type: "UPDATE_BOOKING", |
32 | GameAndSlot: [ |
33 | { id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 }, |
34 | { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 } |
35 | ], |
36 | BookingDetail: [ |
37 | { |
38 | bookingId: "14440074", contact: "9876443111", game: "BasketBall", name: "Roger", slotDate: "6/12/2020", |
39 | slot: { id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" } |
40 | }, |
41 | { |
42 | bookingId: "92303869", contact: "9867844311", game: "FootBall", name: "shelly", slotDate: "6/12/2020", |
43 | slot: { id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" } |
44 | } |
45 | ] |
46 | })).toEqual({ |
47 | Games: [ |
48 | { id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 }, |
49 | { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 } |
50 | ], |
51 | details: [ |
52 | { |
53 | bookingId: "14440074", contact: "9876443111", game: "BasketBall", name: "Roger", slotDate: "6/12/2020", |
54 | slot: { id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" } |
55 | }, |
56 | { |
57 | bookingId: "92303869", contact: "9867844311", game: "FootBall", name: "shelly", slotDate: "6/12/2020", |
58 | slot: { id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" } |
59 | } |
60 | ] |
61 | }); |
62 | }); |
63 | it("select game(onBook)", () => { |
64 | const state = { |
65 | Games: [ |
66 | { id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 }, |
67 | { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 } |
68 | ], |
69 | selectedGame: [] |
70 | }; |
71 | expect(bookNowReducer(state, { type: "SELECT_GAME", id: 1 })).toEqual({ |
72 | Games: [ |
73 | { id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 }, |
74 | { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 } |
75 | ], |
76 | selectedGame: { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 } |
77 | }); |
78 | const next_state = { |
79 | Games: [ |
80 | { id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 }, |
81 | { |
82 | id: 1, src: VolleyBall, name: "VolleyBall", slots: [ |
83 | { id: 1, startTime: "09.00 A.M", endTime: "10.00 A.M", slotStatus: "btn btn-primary" }, |
84 | { id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-success" }, |
85 | { id: 3, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-danger" } |
86 | ] |
87 | } |
88 | ], |
89 | selectedGame: [] |
90 | }; |
91 | expect(bookNowReducer(next_state, { type: "SELECT_GAME", id: 1 })).toEqual({ |
92 | Games: [ |
93 | { id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 }, |
94 | { |
95 | id: 1, src: VolleyBall, name: "VolleyBall", |
96 | slots: [ |
97 | { id: 1, startTime: "09.00 A.M", endTime: "10.00 A.M", slotStatus: "btn btn-success" }, |
98 | { id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-success" }, |
99 | { id: 3, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-danger" } |
100 | ] |
101 | } |
102 | ], |
103 | selectedGame: { |
104 | id: 1, src: VolleyBall, name: "VolleyBall", |
105 | slots: [ |
106 | { id: 1, startTime: "09.00 A.M", endTime: "10.00 A.M", slotStatus: "btn btn-success" }, |
107 | { id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-success" }, |
108 | { id: 3, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-danger" } |
109 | ] |
110 | } |
111 | }); |
112 | }); |
113 | // ..... |
114 | |
115 | it("onShow", () => { |
116 | const state = { |
117 | selectedDate: new Date( |
118 | new Date().getFullYear(), |
119 | new Date().getMonth(), |
120 | new Date().getDate() + 1 |
121 | ) |
122 | }; |
123 | expect( |
124 | bookNowReducer(state, { |
125 | type: "ON_SELECTED_DAY", |
126 | Day: "Wed Mar 11 2020 12:00:00 GMT+0530 (India Standard Time)" |
127 | }) |
128 | ).toEqual({ |
129 | selectedDate: "Wed Mar 11 2020 12:00:00 GMT+0530 (India Standard Time)" |
130 | }); |
131 | }); |
132 | it("on select slot", () => { |
133 | const state = { |
134 | selectedGame: { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 }, |
135 | slotBooked: undefined |
136 | }; |
137 | expect(bookNowReducer(state, { type: "ON_SELECT_SLOT", id: 2 })).toEqual({ |
138 | selectedGame: { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 }, |
139 | slotBooked: { id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-primary" } |
140 | }); |
141 | expect(bookNowReducer(state, { type: "ON_SELECT_SLOT", id: 6 })).toEqual({ |
142 | selectedGame: { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 }, |
143 | slotBooked: |
144 | { id: 6, startTime: "02.00 P.M", endTime: "03.00 P.M", slotStatus: "btn btn-primary" } |
145 | }); |
146 | |
147 | const Nextstate = { |
148 | selectedGame: { |
149 | id: 1, src: VolleyBall, name: "VolleyBall", |
150 | slots: [ |
151 | { id: 1, startTime: "09.00 A.M", endTime: "10.00 A.M", slotStatus: "btn btn-success" }, |
152 | { id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-danger" } |
153 | ] |
154 | }, |
155 | slotBooked: undefined |
156 | |
157 | }; |
158 | expect(bookNowReducer(Nextstate, { type: "ON_SELECT_SLOT", id: 2 })).toEqual({ |
159 | selectedGame: { |
160 | id: 1, src: VolleyBall, name: "VolleyBall", |
161 | slots: [ |
162 | { id: 1, startTime: "09.00 A.M", endTime: "10.00 A.M", slotStatus: "btn btn-success" }, |
163 | { id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-danger" } |
164 | ] |
165 | }, |
166 | slotBooked: undefined |
167 | }); |
168 | |
169 | }); |
170 | it("DONE_BOOKING", () => { |
171 | const state = { |
172 | selectedGame: { |
173 | id: 1, src: VolleyBall, name: "VolleyBall", |
174 | slots: [ |
175 | { id: 1, startTime: "09.00 A.M", endTime: "10.00 A.M", slotStatus: "btn btn-success" }, |
176 | { id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-primary" } |
177 | ] |
178 | }, |
179 | slotBooked: { id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-primary" } |
180 | }; |
181 | expect(bookNowReducer(state, { type: "DONE_BOOKING" })).toEqual({ |
182 | selectedGame: { |
183 | id: 1, src: VolleyBall, name: "VolleyBall", |
184 | slots: [ |
185 | { id: 1, startTime: "09.00 A.M", endTime: "10.00 A.M", slotStatus: "btn btn-success" }, |
186 | { id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-danger" } |
187 | ] |
188 | }, |
189 | slotBooked: undefined |
190 | }) |
191 | }) |
192 | it("doneBooking", () => { |
193 | const state = { |
194 | |
195 | slotBooked: { id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-primary" } |
196 | }; |
197 | expect(bookNowReducer(state, { type: "ICON_CLICK", id: 2 })).toEqual({ |
198 | slotBooked: undefined |
199 | }) |
200 | }) |
201 | |
202 | it("check Booking", () => { |
203 | const state = { |
204 | bookingCheck: [], |
205 | details: [ |
206 | { |
207 | bookingId: "14440074", contact: "9876443111", game: "BasketBall", name: "Roger", slotDate: "6/12/2020", |
208 | slot: |
209 | { id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" } |
210 | }, |
211 | { |
212 | bookingId: "92303869", |
213 | contact: "9867844311", |
214 | game: "FootBall", |
215 | name: "shelly", |
216 | slotDate: "6/12/2020", |
217 | slot: { id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" } |
218 | } |
219 | ] |
220 | }; |
221 | expect( |
222 | bookNowReducer(state, { type: "CHECK_BOOKING", payload: "9230" }) |
223 | ).toEqual({ |
224 | bookingCheck: [ |
225 | { |
226 | bookingId: "92303869", |
227 | contact: "9867844311", |
228 | game: "FootBall", |
229 | name: "shelly", |
230 | slotDate: "6/12/2020", |
231 | slot: |
232 | { id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" } |
233 | } |
234 | ], |
235 | details: [ |
236 | { |
237 | bookingId: "14440074", |
238 | contact: "9876443111", |
239 | game: "BasketBall", |
240 | name: "Roger", |
241 | slotDate: "6/12/2020", |
242 | slot: |
243 | { id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" } |
244 | }, |
245 | { |
246 | bookingId: "92303869", |
247 | contact: "9867844311", |
248 | game: "FootBall", |
249 | name: "shelly", |
250 | slotDate: "6/12/2020", |
251 | slot: |
252 | { id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" } |
253 | } |
254 | ] |
255 | }); |
256 | }); |
257 | }); |
258 |
search.test.js
· 5.9 KiB · JavaScript
Raw
test/search.test.js
import React from "react";
import { Search_Booking } from "../pages/search_booking";
import { shallow } from "enzyme";
import configureStore from "redux-mock-store";
import { configure } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
configure({ adapter: new Adapter() });
const mockStore = configureStore([]);
describe("Search Page", () => {
const historyMock = { push: jest.fn() };
const mockfn1 = jest.fn();
let store;
let emptyDetail;
let component;
let emptyCheck;
let noResult;
beforeEach(() => {
const Details = [
{
bookingId: "92303869",
contact: "9876443111",
game: "BasketBall",
name: "Roger",
slot:
{ id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" }
},
{
bookingId: "14440074",
contact: "9867844311",
game: "FootBall",
name: "shelly",
slot:
{ id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" }
}
]
component = shallow(
<Search_Booking details={Details} check={mockfn1} history={historyMock} check={mockfn1} getGameAndBooking={mockfn1} />
)
});
it("DidMount", () => {
expect(mockfn1).toHaveBeenCalledTimes(1);
})
it("Search page Content", () => {
expect(component.find("header").length).toBe(1);
expect(component.find("header").childAt(0).length).toBe(1);
expect(component.find("header").text()).toEqual("Play Zone ");
component
.find("header")
.find("img")
.simulate("click");
expect(historyMock.push.mock.calls[0]).toEqual(["/"]);
expect(component.find("span").find(".Search").length).toBe(1);
});
it("empty search field", () => {
const tbody = component.find("table tbody");
component
.find(".Search")
.simulate("change", { target: { name: "Search", value: "" } });
expect(component.state().Search).toEqual(undefined);
const table_body1 = tbody.find("tr").map(child => child.render().text());
expect(table_body1).toEqual([
"92303869Roger9876443111BasketBall12.00 P.M-01.00 P.M",
"14440074shelly9867844311FootBall11.00 A.M-12.00 P.M"
]);
});
it("table content after booking happend", () => {
const thead = component.find("table thead");
const table_header = thead.find("tr").map(child => child.text());
expect(table_header).toEqual([
"Booking IDSlot DateNameContact NoGameSlots"
]);
const tbody = component.find("table tbody");
const table_body = tbody.find("tr").map(child => child.render().text());
expect(table_body).toEqual([
"92303869Roger9876443111BasketBall12.00 P.M-01.00 P.M",
"14440074shelly9867844311FootBall11.00 A.M-12.00 P.M"
]);
});
it("no booking", () => {
const emptyDetail = []
const wrapper = shallow(<Search_Booking details={emptyDetail} check={mockfn1} getGameAndBooking={mockfn1} />)
const thead = wrapper.find("table thead");
const table_header = thead.find("tr").map(child => child.text());
expect(table_header).toEqual([
"Booking IDSlot DateNameContact NoGameSlots"
]);
const msg = wrapper.find("p");
expect(msg.text()).toBe("No Booking happend yet");
});
it("search function", () => {
const Booking_Check1 = [
{
bookingId: "14440074",
contact: "9867844311",
game: "FootBall",
name: "shelly",
slot:
{ id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" }
}
]
const Details1 = [
{
bookingId: "92303869",
contact: "9876443111",
game: "BasketBall",
name: "Roger",
slot:
{ id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" }
},
{
bookingId: "14440074",
contact: "9867844311",
game: "FootBall",
name: "shelly",
slot:
{ id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" }
}
]
const component = shallow(<Search_Booking details={Details1} checkBooking={Booking_Check1} check={mockfn1} getGameAndBooking={mockfn1} />)
component
.find(".Search")
.simulate("change", { target: { name: "Search", value: "14440074" } });
expect(component.state().Search).toEqual("14440074");
const thead = component.find("table thead");
const table_header = thead.find("tr").map(child => child.text());
expect(table_header).toEqual([
"Booking IDSlot DateNameContact NoGameSlots"
]);
const tbody = component.find("table tbody");
const table_body = tbody.find("tr").map(child => child.render().text());
expect(table_body).toEqual([
"14440074shelly9867844311FootBall11.00 A.M-12.00 P.M"
]);
});
it("no result found", () => {
const Booking_Check2 = []
const Details2 = [
{
bookingId: "92303869",
contact: "9876443111",
game: "BasketBall",
name: "Roger",
slot:
{
id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success"
}
},
{
bookingId: "14440074",
contact: "9867844311",
game: "FootBall",
name: "shelly",
slot:
{ id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" }
}
]
const component = shallow(<Search_Booking details={Details2} checkBooking={Booking_Check2} check={mockfn1} getGameAndBooking={mockfn1} />)
component
.find(".Search")
.simulate("change", { target: { name: "Search", value: "222" } });
expect(component.state().Search).toEqual("222");
const thead = component.find("table thead");
const table_header = thead.find("tr").map(child => child.text());
expect(table_header).toEqual([
"Booking IDSlot DateNameContact NoGameSlots"
]);
const msg = component.find("p");
expect(msg.text()).toBe("No Booking Found");
});
});
1 | test/search.test.js |
2 | |
3 | import React from "react"; |
4 | import { Search_Booking } from "../pages/search_booking"; |
5 | import { shallow } from "enzyme"; |
6 | import configureStore from "redux-mock-store"; |
7 | import { configure } from "enzyme"; |
8 | import Adapter from "enzyme-adapter-react-16"; |
9 | configure({ adapter: new Adapter() }); |
10 | |
11 | const mockStore = configureStore([]); |
12 | describe("Search Page", () => { |
13 | const historyMock = { push: jest.fn() }; |
14 | const mockfn1 = jest.fn(); |
15 | let store; |
16 | let emptyDetail; |
17 | let component; |
18 | let emptyCheck; |
19 | let noResult; |
20 | beforeEach(() => { |
21 | const Details = [ |
22 | { |
23 | bookingId: "92303869", |
24 | contact: "9876443111", |
25 | game: "BasketBall", |
26 | name: "Roger", |
27 | slot: |
28 | { id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" } |
29 | }, |
30 | { |
31 | bookingId: "14440074", |
32 | contact: "9867844311", |
33 | game: "FootBall", |
34 | name: "shelly", |
35 | slot: |
36 | { id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" } |
37 | |
38 | } |
39 | ] |
40 | |
41 | component = shallow( |
42 | <Search_Booking details={Details} check={mockfn1} history={historyMock} check={mockfn1} getGameAndBooking={mockfn1} /> |
43 | ) |
44 | |
45 | }); |
46 | it("DidMount", () => { |
47 | expect(mockfn1).toHaveBeenCalledTimes(1); |
48 | }) |
49 | it("Search page Content", () => { |
50 | expect(component.find("header").length).toBe(1); |
51 | expect(component.find("header").childAt(0).length).toBe(1); |
52 | expect(component.find("header").text()).toEqual("Play Zone "); |
53 | component |
54 | .find("header") |
55 | .find("img") |
56 | .simulate("click"); |
57 | expect(historyMock.push.mock.calls[0]).toEqual(["/"]); |
58 | expect(component.find("span").find(".Search").length).toBe(1); |
59 | }); |
60 | it("empty search field", () => { |
61 | const tbody = component.find("table tbody"); |
62 | component |
63 | .find(".Search") |
64 | .simulate("change", { target: { name: "Search", value: "" } }); |
65 | expect(component.state().Search).toEqual(undefined); |
66 | const table_body1 = tbody.find("tr").map(child => child.render().text()); |
67 | expect(table_body1).toEqual([ |
68 | "92303869Roger9876443111BasketBall12.00 P.M-01.00 P.M", |
69 | "14440074shelly9867844311FootBall11.00 A.M-12.00 P.M" |
70 | ]); |
71 | }); |
72 | it("table content after booking happend", () => { |
73 | const thead = component.find("table thead"); |
74 | const table_header = thead.find("tr").map(child => child.text()); |
75 | expect(table_header).toEqual([ |
76 | "Booking IDSlot DateNameContact NoGameSlots" |
77 | ]); |
78 | const tbody = component.find("table tbody"); |
79 | const table_body = tbody.find("tr").map(child => child.render().text()); |
80 | expect(table_body).toEqual([ |
81 | "92303869Roger9876443111BasketBall12.00 P.M-01.00 P.M", |
82 | "14440074shelly9867844311FootBall11.00 A.M-12.00 P.M" |
83 | ]); |
84 | }); |
85 | it("no booking", () => { |
86 | const emptyDetail = [] |
87 | const wrapper = shallow(<Search_Booking details={emptyDetail} check={mockfn1} getGameAndBooking={mockfn1} />) |
88 | const thead = wrapper.find("table thead"); |
89 | const table_header = thead.find("tr").map(child => child.text()); |
90 | expect(table_header).toEqual([ |
91 | "Booking IDSlot DateNameContact NoGameSlots" |
92 | ]); |
93 | const msg = wrapper.find("p"); |
94 | expect(msg.text()).toBe("No Booking happend yet"); |
95 | }); |
96 | it("search function", () => { |
97 | const Booking_Check1 = [ |
98 | { |
99 | bookingId: "14440074", |
100 | contact: "9867844311", |
101 | game: "FootBall", |
102 | name: "shelly", |
103 | slot: |
104 | { id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" } |
105 | } |
106 | ] |
107 | const Details1 = [ |
108 | { |
109 | bookingId: "92303869", |
110 | contact: "9876443111", |
111 | game: "BasketBall", |
112 | name: "Roger", |
113 | slot: |
114 | { id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" } |
115 | }, |
116 | { |
117 | bookingId: "14440074", |
118 | contact: "9867844311", |
119 | game: "FootBall", |
120 | name: "shelly", |
121 | slot: |
122 | { id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" } |
123 | |
124 | } |
125 | ] |
126 | |
127 | const component = shallow(<Search_Booking details={Details1} checkBooking={Booking_Check1} check={mockfn1} getGameAndBooking={mockfn1} />) |
128 | |
129 | component |
130 | .find(".Search") |
131 | .simulate("change", { target: { name: "Search", value: "14440074" } }); |
132 | expect(component.state().Search).toEqual("14440074"); |
133 | const thead = component.find("table thead"); |
134 | const table_header = thead.find("tr").map(child => child.text()); |
135 | expect(table_header).toEqual([ |
136 | "Booking IDSlot DateNameContact NoGameSlots" |
137 | ]); |
138 | const tbody = component.find("table tbody"); |
139 | const table_body = tbody.find("tr").map(child => child.render().text()); |
140 | expect(table_body).toEqual([ |
141 | "14440074shelly9867844311FootBall11.00 A.M-12.00 P.M" |
142 | ]); |
143 | }); |
144 | it("no result found", () => { |
145 | const Booking_Check2 = [] |
146 | const Details2 = [ |
147 | { |
148 | bookingId: "92303869", |
149 | contact: "9876443111", |
150 | game: "BasketBall", |
151 | name: "Roger", |
152 | slot: |
153 | { |
154 | id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" |
155 | } |
156 | }, |
157 | { |
158 | bookingId: "14440074", |
159 | contact: "9867844311", |
160 | game: "FootBall", |
161 | name: "shelly", |
162 | slot: |
163 | { id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" } |
164 | } |
165 | ] |
166 | const component = shallow(<Search_Booking details={Details2} checkBooking={Booking_Check2} check={mockfn1} getGameAndBooking={mockfn1} />) |
167 | |
168 | component |
169 | .find(".Search") |
170 | .simulate("change", { target: { name: "Search", value: "222" } }); |
171 | expect(component.state().Search).toEqual("222"); |
172 | const thead = component.find("table thead"); |
173 | const table_header = thead.find("tr").map(child => child.text()); |
174 | expect(table_header).toEqual([ |
175 | "Booking IDSlot DateNameContact NoGameSlots" |
176 | ]); |
177 | const msg = component.find("p"); |
178 | expect(msg.text()).toBe("No Booking Found"); |
179 | }); |
180 | }); |
181 |
searchbookings.js
· 1.9 KiB · JavaScript
Raw
pages/searchbookings.js
import React, { Component } from "react";
import { connect } from "react-redux";
import { checkBooking } from "../Action/action";
import icon from "../images/football.svg";
export class Search_Booking extends Component {
state = {
Search: undefined
};
handleHomePage = () => {
//route to home page
};
render() {
return (
<div>
<div className="Home">
<header>
{/* header content goes here */}
<img
alt=""
id="icon"
width="40px"
height="40px"
src={icon}
onClick={this.handleHomePage}
/>
</header>
</div>
<div>
<span>
{/* input field for the search field goes here with name "Search" */}
</span>
<div>
<table>
<thead>
<tr id="Book_List_header">
<td id="Book_List_header">Booking ID</td>
<td id="Book_List_header">Slot Date</td>
<td id="Book_List_header">Name</td>
<td id="Book_List_header">Contact No</td>
<td id="Book_List_header">Game</td>
<td id="Book_List_header">Slots</td>
</tr>
</thead>
</table>
{/* Display the Booking Details
use id as Book_List for td and ClassName as Booking_List for tr and tbody */}
</div>
</div>
</div>
);
}
}
const mapStateToProps = state => {
return {
checkBooking: state.bookingCheck,
details: state.details
};
};
const mapDispatchToProps = dispatch => {
return {
check: payload => dispatch(checkBooking(payload)),
getGameAndBooking: () => dispatch({ type: "GAME_BOOKING" })
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(Search_Booking);
1 | pages/searchbookings.js |
2 | |
3 | import React, { Component } from "react"; |
4 | import { connect } from "react-redux"; |
5 | import { checkBooking } from "../Action/action"; |
6 | import icon from "../images/football.svg"; |
7 | export class Search_Booking extends Component { |
8 | state = { |
9 | Search: undefined |
10 | }; |
11 | |
12 | handleHomePage = () => { |
13 | //route to home page |
14 | }; |
15 | |
16 | render() { |
17 | return ( |
18 | <div> |
19 | <div className="Home"> |
20 | <header> |
21 | {/* header content goes here */} |
22 | <img |
23 | alt="" |
24 | id="icon" |
25 | width="40px" |
26 | height="40px" |
27 | src={icon} |
28 | onClick={this.handleHomePage} |
29 | /> |
30 | </header> |
31 | </div> |
32 | <div> |
33 | <span> |
34 | {/* input field for the search field goes here with name "Search" */} |
35 | </span> |
36 | <div> |
37 | <table> |
38 | <thead> |
39 | <tr id="Book_List_header"> |
40 | <td id="Book_List_header">Booking ID</td> |
41 | <td id="Book_List_header">Slot Date</td> |
42 | <td id="Book_List_header">Name</td> |
43 | <td id="Book_List_header">Contact No</td> |
44 | <td id="Book_List_header">Game</td> |
45 | <td id="Book_List_header">Slots</td> |
46 | </tr> |
47 | </thead> |
48 | </table> |
49 | {/* Display the Booking Details |
50 | use id as Book_List for td and ClassName as Booking_List for tr and tbody */} |
51 | </div> |
52 | </div> |
53 | </div> |
54 | ); |
55 | } |
56 | } |
57 | |
58 | const mapStateToProps = state => { |
59 | return { |
60 | checkBooking: state.bookingCheck, |
61 | details: state.details |
62 | }; |
63 | }; |
64 | const mapDispatchToProps = dispatch => { |
65 | return { |
66 | check: payload => dispatch(checkBooking(payload)), |
67 | getGameAndBooking: () => dispatch({ type: "GAME_BOOKING" }) |
68 | }; |
69 | }; |
70 | |
71 | export default connect( |
72 | mapStateToProps, |
73 | mapDispatchToProps |
74 | )(Search_Booking); |
75 | |
76 |
slot.js
· 908 B · JavaScript
Raw
Components/slot.js
import React, { Component } from "react";
import { connect } from "react-redux";
import { selectSlot } from "../Action/action";
class Slots extends Component {
handleSlot = id => {
this.props.selectSlot(id);
};
render() {
// Template for each slot
// <div key={slot.id} className="slot_list">
// <h4>
// <span
// className={slot.slotStatus}
// style={{ cursor: "pointer" }}
// >
// </span>
// </h4>
// </div>
return (<div>
{/* code for slot goes here */}
</div>);
}
}
const mapStateToProps = state => {
return {
selectedGame: state.selectedGame,
bookingSlot: state.slotBooked
};
};
const mapDispatchToProps = dispatch => {
return {
selectSlot: id => dispatch(selectSlot(id))
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(Slots);
1 | Components/slot.js |
2 | |
3 | import React, { Component } from "react"; |
4 | import { connect } from "react-redux"; |
5 | import { selectSlot } from "../Action/action"; |
6 | class Slots extends Component { |
7 | handleSlot = id => { |
8 | this.props.selectSlot(id); |
9 | }; |
10 | |
11 | render() { |
12 | // Template for each slot |
13 | // <div key={slot.id} className="slot_list"> |
14 | // <h4> |
15 | // <span |
16 | // className={slot.slotStatus} |
17 | // style={{ cursor: "pointer" }} |
18 | // > |
19 | |
20 | // </span> |
21 | // </h4> |
22 | // </div> |
23 | |
24 | return (<div> |
25 | {/* code for slot goes here */} |
26 | </div>); |
27 | } |
28 | } |
29 | |
30 | const mapStateToProps = state => { |
31 | return { |
32 | selectedGame: state.selectedGame, |
33 | bookingSlot: state.slotBooked |
34 | }; |
35 | }; |
36 | const mapDispatchToProps = dispatch => { |
37 | return { |
38 | selectSlot: id => dispatch(selectSlot(id)) |
39 | }; |
40 | }; |
41 | |
42 | export default connect( |
43 | mapStateToProps, |
44 | mapDispatchToProps |
45 | )(Slots); |
46 |
slot.test.js
· 3.0 KiB · JavaScript
Raw
test/slot.test.js
import React from "react";
import Slots from "../Component/slot";
import { shallow } from "enzyme";
import configureStore from "redux-mock-store";
import { configure } from "enzyme";
import Adapter from "enzyme-adapter-react-16";
import BasketBall from "../images/basket_ball.jpeg";
import VolleyBall from "../images/volleyBall.jpeg";
import cricket from "../images/cricket_bat.jpg";
import FootBall from "../images/football.jpeg";
import {
bookSlot1,
bookSlot2,
bookSlot3,
bookSlot4
} from "../Component/slot_data";
configure({ adapter: new Adapter() });
const mockStore = configureStore([]);
describe("Slot component", () => {
const mockfn1 = jest.fn();
let store;
let component;
beforeEach(() => {
store = mockStore({
Games: [
{ id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 },
{ id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 },
{ id: 2, src: cricket, name: "Cricket", slots: bookSlot3 },
{ id: 3, src: FootBall, name: "FootBall", slots: bookSlot4 }
],
selectedGame: {
id: 1,
src: VolleyBall,
name: "VolleyBall",
slots: [
{ id: 1, startTime: "09.00 A.M", endTime: "10.00 A.M", slotStatus: "btn btn-success" },
{ id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-success" },
{ id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" },
{ id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" },
{ id: 5, startTime: "01.00 P.M", endTime: "02.00 P.M", slotStatus: "btn btn-success" },
{ id: 6, startTime: "02.00 P.M", endTime: "03.00 P.M", slotStatus: "btn btn-success" },
{ id: 7, startTime: "03.00 P.M", endTime: "04.00 P.M", slotStatus: "btn btn-success" },
{ id: 8, startTime: "04.00 P.M", endTime: "05.00 P.M", slotStatus: "btn btn-success" },
{ id: 9, startTime: "05.00 P.M", endTime: "06.00 P.M", slotStatus: "btn btn-success" }
]
},
selectedDate: new Date(
new Date().getFullYear(),
new Date().getMonth(),
new Date().getDate() + 1
),
slotBooked: [],
details: []
});
component = shallow(<Slots store={store} Select_Slot={mockfn1} />)
.childAt(0)
.dive();
});
it("Slot Content", () => {
let slot = component.find(".slot_list");
const Product = slot.find("h4").map(child => child.text());
expect(Product).toEqual([
"09.00 A.M - 10.00 A.M",
"10.00 A.M - 11.00 A.M",
"11.00 A.M - 12.00 P.M",
"12.00 P.M - 01.00 P.M",
"01.00 P.M - 02.00 P.M",
"02.00 P.M - 03.00 P.M",
"03.00 P.M - 04.00 P.M",
"04.00 P.M - 05.00 P.M",
"05.00 P.M - 06.00 P.M"
]);
});
it("handle_Slot", () => {
const spy = jest.spyOn(component.instance(), "handleSlot");
let slot = component
.find(".slot_list")
.find("h4")
.find("span")
.at(3);
slot.simulate("click");
expect(spy).toBeCalledTimes(1);
});
});
1 | test/slot.test.js |
2 | |
3 | import React from "react"; |
4 | import Slots from "../Component/slot"; |
5 | import { shallow } from "enzyme"; |
6 | import configureStore from "redux-mock-store"; |
7 | import { configure } from "enzyme"; |
8 | import Adapter from "enzyme-adapter-react-16"; |
9 | import BasketBall from "../images/basket_ball.jpeg"; |
10 | import VolleyBall from "../images/volleyBall.jpeg"; |
11 | import cricket from "../images/cricket_bat.jpg"; |
12 | import FootBall from "../images/football.jpeg"; |
13 | import { |
14 | bookSlot1, |
15 | bookSlot2, |
16 | bookSlot3, |
17 | bookSlot4 |
18 | } from "../Component/slot_data"; |
19 | |
20 | configure({ adapter: new Adapter() }); |
21 | |
22 | const mockStore = configureStore([]); |
23 | describe("Slot component", () => { |
24 | const mockfn1 = jest.fn(); |
25 | let store; |
26 | let component; |
27 | beforeEach(() => { |
28 | store = mockStore({ |
29 | Games: [ |
30 | { id: 0, src: BasketBall, name: "BasketBall", slots: bookSlot1 }, |
31 | { id: 1, src: VolleyBall, name: "VolleyBall", slots: bookSlot2 }, |
32 | { id: 2, src: cricket, name: "Cricket", slots: bookSlot3 }, |
33 | { id: 3, src: FootBall, name: "FootBall", slots: bookSlot4 } |
34 | ], |
35 | selectedGame: { |
36 | id: 1, |
37 | src: VolleyBall, |
38 | name: "VolleyBall", |
39 | slots: [ |
40 | { id: 1, startTime: "09.00 A.M", endTime: "10.00 A.M", slotStatus: "btn btn-success" }, |
41 | { id: 2, startTime: "10.00 A.M", endTime: "11.00 A.M", slotStatus: "btn btn-success" }, |
42 | { id: 3, startTime: "11.00 A.M", endTime: "12.00 P.M", slotStatus: "btn btn-success" }, |
43 | { id: 4, startTime: "12.00 P.M", endTime: "01.00 P.M", slotStatus: "btn btn-success" }, |
44 | { id: 5, startTime: "01.00 P.M", endTime: "02.00 P.M", slotStatus: "btn btn-success" }, |
45 | { id: 6, startTime: "02.00 P.M", endTime: "03.00 P.M", slotStatus: "btn btn-success" }, |
46 | { id: 7, startTime: "03.00 P.M", endTime: "04.00 P.M", slotStatus: "btn btn-success" }, |
47 | { id: 8, startTime: "04.00 P.M", endTime: "05.00 P.M", slotStatus: "btn btn-success" }, |
48 | { id: 9, startTime: "05.00 P.M", endTime: "06.00 P.M", slotStatus: "btn btn-success" } |
49 | ] |
50 | }, |
51 | selectedDate: new Date( |
52 | new Date().getFullYear(), |
53 | new Date().getMonth(), |
54 | new Date().getDate() + 1 |
55 | ), |
56 | slotBooked: [], |
57 | details: [] |
58 | }); |
59 | component = shallow(<Slots store={store} Select_Slot={mockfn1} />) |
60 | .childAt(0) |
61 | .dive(); |
62 | }); |
63 | it("Slot Content", () => { |
64 | let slot = component.find(".slot_list"); |
65 | const Product = slot.find("h4").map(child => child.text()); |
66 | expect(Product).toEqual([ |
67 | "09.00 A.M - 10.00 A.M", |
68 | "10.00 A.M - 11.00 A.M", |
69 | "11.00 A.M - 12.00 P.M", |
70 | "12.00 P.M - 01.00 P.M", |
71 | "01.00 P.M - 02.00 P.M", |
72 | "02.00 P.M - 03.00 P.M", |
73 | "03.00 P.M - 04.00 P.M", |
74 | "04.00 P.M - 05.00 P.M", |
75 | "05.00 P.M - 06.00 P.M" |
76 | ]); |
77 | }); |
78 | it("handle_Slot", () => { |
79 | const spy = jest.spyOn(component.instance(), "handleSlot"); |
80 | let slot = component |
81 | .find(".slot_list") |
82 | .find("h4") |
83 | .find("span") |
84 | .at(3); |
85 | slot.simulate("click"); |
86 | expect(spy).toBeCalledTimes(1); |
87 | }); |
88 | }); |
89 |
slot_data.js
· 3.9 KiB · JavaScript
Raw
Components/slot_data.js
export const bookSlot1 = [
{
id: 1,
startTime: "09.00 A.M",
endTime: "10.00 A.M",
slotStatus: "btn btn-success"
},
{
id: 2,
startTime: "10.00 A.M",
endTime: "11.00 A.M",
slotStatus: "btn btn-success"
},
{
id: 3,
startTime: "11.00 A.M",
endTime: "12.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 4,
startTime: "12.00 P.M",
endTime: "01.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 5,
startTime: "01.00 P.M",
endTime: "02.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 6,
startTime: "02.00 P.M",
endTime: "03.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 7,
startTime: "03.00 P.M",
endTime: "04.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 8,
startTime: "04.00 P.M",
endTime: "05.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 9,
startTime: "05.00 P.M",
endTime: "06.00 P.M",
slotStatus: "btn btn-success"
}
];
export const bookSlot2 = [
{
id: 1,
startTime: "09.00 A.M",
endTime: "10.00 A.M",
slotStatus: "btn btn-success"
},
{
id: 2,
startTime: "10.00 A.M",
endTime: "11.00 A.M",
slotStatus: "btn btn-success"
},
{
id: 3,
startTime: "11.00 A.M",
endTime: "12.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 4,
startTime: "12.00 P.M",
endTime: "01.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 5,
startTime: "01.00 P.M",
endTime: "02.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 6,
startTime: "02.00 P.M",
endTime: "03.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 7,
startTime: "03.00 P.M",
endTime: "04.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 8,
startTime: "04.00 P.M",
endTime: "05.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 9,
startTime: "05.00 P.M",
endTime: "06.00 P.M",
slotStatus: "btn btn-success"
}
];
export const bookSlot3 = [
{
id: 1,
startTime: "09.00 A.M",
endTime: "10.00 A.M",
slotStatus: "btn btn-success"
},
{
id: 2,
startTime: "10.00 A.M",
endTime: "11.00 A.M",
slotStatus: "btn btn-success"
},
{
id: 3,
startTime: "11.00 A.M",
endTime: "12.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 4,
startTime: "12.00 P.M",
endTime: "01.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 5,
startTime: "01.00 P.M",
endTime: "02.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 6,
startTime: "02.00 P.M",
endTime: "03.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 7,
startTime: "03.00 P.M",
endTime: "04.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 8,
startTime: "04.00 P.M",
endTime: "05.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 9,
startTime: "05.00 P.M",
endTime: "06.00 P.M",
slotStatus: "btn btn-success"
}
];
export const bookSlot4 = [
{
id: 1,
startTime: "09.00 A.M",
endTime: "10.00 A.M",
slotStatus: "btn btn-success"
},
{
id: 2,
startTime: "10.00 A.M",
endTime: "11.00 A.M",
slotStatus: "btn btn-success"
},
{
id: 3,
startTime: "11.00 A.M",
endTime: "12.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 4,
startTime: "12.00 P.M",
endTime: "01.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 5,
startTime: "01.00 P.M",
endTime: "02.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 6,
startTime: "02.00 P.M",
endTime: "03.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 7,
startTime: "03.00 P.M",
endTime: "04.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 8,
startTime: "04.00 P.M",
endTime: "05.00 P.M",
slotStatus: "btn btn-success"
},
{
id: 9,
startTime: "05.00 P.M",
endTime: "06.00 P.M",
slotStatus: "btn btn-success"
}
];
1 | Components/slot_data.js |
2 | |
3 | |
4 | export const bookSlot1 = [ |
5 | { |
6 | id: 1, |
7 | startTime: "09.00 A.M", |
8 | endTime: "10.00 A.M", |
9 | slotStatus: "btn btn-success" |
10 | }, |
11 | { |
12 | id: 2, |
13 | startTime: "10.00 A.M", |
14 | endTime: "11.00 A.M", |
15 | slotStatus: "btn btn-success" |
16 | }, |
17 | { |
18 | id: 3, |
19 | startTime: "11.00 A.M", |
20 | endTime: "12.00 P.M", |
21 | slotStatus: "btn btn-success" |
22 | }, |
23 | { |
24 | id: 4, |
25 | startTime: "12.00 P.M", |
26 | endTime: "01.00 P.M", |
27 | slotStatus: "btn btn-success" |
28 | }, |
29 | { |
30 | id: 5, |
31 | startTime: "01.00 P.M", |
32 | endTime: "02.00 P.M", |
33 | slotStatus: "btn btn-success" |
34 | }, |
35 | { |
36 | id: 6, |
37 | startTime: "02.00 P.M", |
38 | endTime: "03.00 P.M", |
39 | slotStatus: "btn btn-success" |
40 | }, |
41 | { |
42 | id: 7, |
43 | startTime: "03.00 P.M", |
44 | endTime: "04.00 P.M", |
45 | slotStatus: "btn btn-success" |
46 | }, |
47 | { |
48 | id: 8, |
49 | startTime: "04.00 P.M", |
50 | endTime: "05.00 P.M", |
51 | slotStatus: "btn btn-success" |
52 | }, |
53 | { |
54 | id: 9, |
55 | startTime: "05.00 P.M", |
56 | endTime: "06.00 P.M", |
57 | slotStatus: "btn btn-success" |
58 | } |
59 | ]; |
60 | |
61 | export const bookSlot2 = [ |
62 | { |
63 | id: 1, |
64 | startTime: "09.00 A.M", |
65 | endTime: "10.00 A.M", |
66 | slotStatus: "btn btn-success" |
67 | }, |
68 | { |
69 | id: 2, |
70 | startTime: "10.00 A.M", |
71 | endTime: "11.00 A.M", |
72 | slotStatus: "btn btn-success" |
73 | }, |
74 | { |
75 | id: 3, |
76 | startTime: "11.00 A.M", |
77 | endTime: "12.00 P.M", |
78 | slotStatus: "btn btn-success" |
79 | }, |
80 | { |
81 | id: 4, |
82 | startTime: "12.00 P.M", |
83 | endTime: "01.00 P.M", |
84 | slotStatus: "btn btn-success" |
85 | }, |
86 | { |
87 | id: 5, |
88 | startTime: "01.00 P.M", |
89 | endTime: "02.00 P.M", |
90 | slotStatus: "btn btn-success" |
91 | }, |
92 | { |
93 | id: 6, |
94 | startTime: "02.00 P.M", |
95 | endTime: "03.00 P.M", |
96 | slotStatus: "btn btn-success" |
97 | }, |
98 | { |
99 | id: 7, |
100 | startTime: "03.00 P.M", |
101 | endTime: "04.00 P.M", |
102 | slotStatus: "btn btn-success" |
103 | }, |
104 | { |
105 | id: 8, |
106 | startTime: "04.00 P.M", |
107 | endTime: "05.00 P.M", |
108 | slotStatus: "btn btn-success" |
109 | }, |
110 | { |
111 | id: 9, |
112 | startTime: "05.00 P.M", |
113 | endTime: "06.00 P.M", |
114 | slotStatus: "btn btn-success" |
115 | } |
116 | ]; |
117 | export const bookSlot3 = [ |
118 | { |
119 | id: 1, |
120 | startTime: "09.00 A.M", |
121 | endTime: "10.00 A.M", |
122 | slotStatus: "btn btn-success" |
123 | }, |
124 | { |
125 | id: 2, |
126 | startTime: "10.00 A.M", |
127 | endTime: "11.00 A.M", |
128 | slotStatus: "btn btn-success" |
129 | }, |
130 | { |
131 | id: 3, |
132 | startTime: "11.00 A.M", |
133 | endTime: "12.00 P.M", |
134 | slotStatus: "btn btn-success" |
135 | }, |
136 | { |
137 | id: 4, |
138 | startTime: "12.00 P.M", |
139 | endTime: "01.00 P.M", |
140 | slotStatus: "btn btn-success" |
141 | }, |
142 | { |
143 | id: 5, |
144 | startTime: "01.00 P.M", |
145 | endTime: "02.00 P.M", |
146 | slotStatus: "btn btn-success" |
147 | }, |
148 | { |
149 | id: 6, |
150 | startTime: "02.00 P.M", |
151 | endTime: "03.00 P.M", |
152 | slotStatus: "btn btn-success" |
153 | }, |
154 | { |
155 | id: 7, |
156 | startTime: "03.00 P.M", |
157 | endTime: "04.00 P.M", |
158 | slotStatus: "btn btn-success" |
159 | }, |
160 | { |
161 | id: 8, |
162 | startTime: "04.00 P.M", |
163 | endTime: "05.00 P.M", |
164 | slotStatus: "btn btn-success" |
165 | }, |
166 | { |
167 | id: 9, |
168 | startTime: "05.00 P.M", |
169 | endTime: "06.00 P.M", |
170 | slotStatus: "btn btn-success" |
171 | } |
172 | ]; |
173 | export const bookSlot4 = [ |
174 | { |
175 | id: 1, |
176 | startTime: "09.00 A.M", |
177 | endTime: "10.00 A.M", |
178 | slotStatus: "btn btn-success" |
179 | }, |
180 | { |
181 | id: 2, |
182 | startTime: "10.00 A.M", |
183 | endTime: "11.00 A.M", |
184 | slotStatus: "btn btn-success" |
185 | }, |
186 | { |
187 | id: 3, |
188 | startTime: "11.00 A.M", |
189 | endTime: "12.00 P.M", |
190 | slotStatus: "btn btn-success" |
191 | }, |
192 | { |
193 | id: 4, |
194 | startTime: "12.00 P.M", |
195 | endTime: "01.00 P.M", |
196 | slotStatus: "btn btn-success" |
197 | }, |
198 | { |
199 | id: 5, |
200 | startTime: "01.00 P.M", |
201 | endTime: "02.00 P.M", |
202 | slotStatus: "btn btn-success" |
203 | }, |
204 | { |
205 | id: 6, |
206 | startTime: "02.00 P.M", |
207 | endTime: "03.00 P.M", |
208 | slotStatus: "btn btn-success" |
209 | }, |
210 | { |
211 | id: 7, |
212 | startTime: "03.00 P.M", |
213 | endTime: "04.00 P.M", |
214 | slotStatus: "btn btn-success" |
215 | }, |
216 | { |
217 | id: 8, |
218 | startTime: "04.00 P.M", |
219 | endTime: "05.00 P.M", |
220 | slotStatus: "btn btn-success" |
221 | }, |
222 | { |
223 | id: 9, |
224 | startTime: "05.00 P.M", |
225 | endTime: "06.00 P.M", |
226 | slotStatus: "btn btn-success" |
227 | } |
228 | ]; |
229 |