Skip to content

Commit

Permalink
test(*): add Reservation.end() test
Browse files Browse the repository at this point in the history
  • Loading branch information
garrappachc committed Dec 27, 2023
1 parent 88e4160 commit dc0e361
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/reservation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ vi.mock('./client', () => {
const Client = vi.fn();
Client.prototype.httpClient = {
get: vi.fn().mockResolvedValue({
data: {
reservation: {
...mockReservationResponse,
status: 'Ready',
},
},
}),
delete: vi.fn().mockResolvedValue({
data: {
reservation: {
...mockReservationResponse,
Expand All @@ -58,10 +66,11 @@ vi.mock('./client', () => {
});

describe('Reservation', () => {
let client: Client;
let reservation: Reservation;

beforeEach(() => {
const client = new Client({
client = new Client({
apiKey: 'FAKE_API_KEY',
endpoint: 'FAKE_SERVEME_ENDPOINT',
});
Expand Down Expand Up @@ -109,9 +118,20 @@ describe('Reservation', () => {
});
});

describe('#refresh', () => {
describe('#refresh()', () => {
it('should refresh reservation details', async () => {
await reservation.refresh();
expect(client.httpClient.get).toHaveBeenCalledWith('/reservations/12345');
expect(reservation.status).toEqual(ReservationStatus.ready);
});
});

describe('#end()', () => {
it('should call the API', async () => {
await reservation.end();
expect(client.httpClient.delete).toHaveBeenCalledWith(
'/reservations/12345',
);
expect(reservation.status).toEqual(ReservationStatus.ending);
});
});
Expand Down

0 comments on commit dc0e361

Please sign in to comment.