Skip to content

Commit

Permalink
Add api tests for /api/vehicle/types
Browse files Browse the repository at this point in the history
  • Loading branch information
chan4lk committed Mar 22, 2023
1 parent 2d268fe commit e64e237
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 14 deletions.
13 changes: 0 additions & 13 deletions hackathons/hack-flash/cypress/e2e/1-getting-started/smoke.cy.js

This file was deleted.

40 changes: 40 additions & 0 deletions hackathons/hack-flash/cypress/e2e/api/vehicle-types.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/// <reference types="cypress" />

describe('Get Vehicle Types Api', () => {
beforeEach(() => {
// SET Base url from CYPRESS_BASE_URL env variable
cy.visit('/')
})

it('should contain all vehicle types', () => {

cy.request('/api/vehicle/types').as('types');

cy.get('@types').should((response) => {
expect(response.body).to.have.lengthOf(5)
})
})

it('should contain CAR vehicle type', () => {

cy.request('/api/vehicle/types').as('types');

cy.get('@types').should((response) => {
console.log(response.body);
const car = response.body.find(x => x.name.toLowerCase() == 'car');
expect(car.quota).to.equal(20);
})
})

it('should contain BUS vehicle type', () => {

cy.request('/api/vehicle/types').as('types');

cy.get('@types').should((response) => {
console.log(response.body);
const car = response.body.find(x => x.name.toLowerCase() == 'bus');
expect(car.quota).to.equal(40);
})
})

})
3 changes: 2 additions & 1 deletion hackathons/hack-flash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "Hack Flash Tests",
"main": "index.js",
"scripts": {
"test": "cypress run"
"test": "cypress run",
"test:watch": "cypress open"
},
"repository": {
"type": "git",
Expand Down
3 changes: 3 additions & 0 deletions test-local.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cd hackathons/hack-flash
SET CYPRESS_BASE_URL=http://localhost:3000
npm run test:watch

0 comments on commit e64e237

Please sign in to comment.