{"size": 2315, "ext": "js", "max_stars_repo_path": "test/services/services.test.js", "max_stars_repo_name": "jaspal-carleton/panoramic_hotel", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/services/services.test.js", "max_issues_repo_name": "jaspal-carleton/panoramic_hotel", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/services/services.test.js", "max_forks_repo_name": "jaspal-carleton/panoramic_hotel", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.2317073171, "max_line_length": 69, "alphanum_fraction": 0.482937365}
require("rootpath")();

/**
 * Test libraries 
 */
const chai = require("chai");
const expect = chai.expect;
const assert = chai.assert;

const serviceBooking = require("app/services/booking");

/**
 * Test suite for booking services
 */
describe("Test Suite - Booking Service Functions", function () {
    let bookingId = "";

    describe("Create Booking", function () {
        it("should create new booking", function () {
            const result = serviceBooking.createBooking(
                "john.doe@example.com",
                "John",
                "Doe",
                2,
                "2022-12-10",
                "2022-12-12"
            );
            result.then( res => {
                expect(res).to.have.property('id');
                bookingId = res.id;
            })
        });

        it("should not create booking with same dates", function () {
            const result = serviceBooking.createBooking(
                "jane.doe@example.com",
                "Jane",
                "Doe",
                2,
                "2022-12-10",
                "2022-12-12"
            );
            result.then( res => {
                expect(res.status).to.be.false;
            })
        });
    });

    describe("Fetch Booking", function () {
        it("should retrieve existing booking", function () {
            const result = serviceBooking.fetchBooking(bookingId);
            result.then( res => {
                expect(res.data).to.have.property('email');
            })
        });

        it("should fail to retrieve wrong booking", function () {
            const result = serviceBooking.fetchBooking("xyz");
            result.then( res => {
                expect(res.status).to.be.false;
            })
        });
    });

    describe("Delete Booking", function () {
        it("should delete existing booking", function () {
            const result = serviceBooking.deleteBooking(bookingId);
            result.then( res => {
                expect(res.status).to.be.true;
            })
        });

        it("should fail to delete wrong booking", function () {
            const result = serviceBooking.deleteBooking("xyz");
            result.then( res => {
                expect(res.status).to.be.false;
            })
        });
    });
    
});
