-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// mockStandings.test.js | ||
const supertest = require('supertest'); | ||
let chai; | ||
before(async () => { | ||
chai = await import('chai'); | ||
}); | ||
|
||
const app = require('../server'); // Adjust the path to your Express app | ||
const request = supertest(app); | ||
|
||
let expect; | ||
before(async () => { | ||
const chai = await import('chai'); | ||
expect = chai.expect; | ||
}); | ||
|
||
describe('Mock Football League Standings Backend Server', () => { | ||
const mockCompetitionCode = 'PL'; // Adjust based on your mock data | ||
const invalidCompetitionCode = 'INVALID_CODE'; | ||
|
||
it('should retrieve a mock standing by competition code', async () => { | ||
const response = await request.get(`/mock/standings/${mockCompetitionCode}`); | ||
expect(response.status).to.equal(200); | ||
expect(response.body).to.have.property('success', true); | ||
expect(response.body).to.have.property('data').that.is.an('object'); | ||
}); | ||
|
||
it('should simulate the creation of a new standing', async () => { | ||
const response = await request.post(`/mock/standings/${mockCompetitionCode}`).send({ /* Mock payload */ }); | ||
expect(response.status).to.equal(201); | ||
expect(response.body).to.have.property('success', true); | ||
expect(response.body).to.have.property('data').that.is.an('object'); | ||
}); | ||
|
||
it('should simulate updating a standing', async () => { | ||
const response = await request.put(`/mock/standings/${mockCompetitionCode}`).send({ /* Mock update payload */ }); | ||
expect(response.status).to.equal(200); | ||
expect(response.body).to.have.property('success', true); | ||
expect(response.body).to.have.property('message', 'Mock update successful'); | ||
}); | ||
|
||
it('should simulate deleting a standing by competition code', async () => { | ||
const response = await request.delete(`/mock/standings/${mockCompetitionCode}`); | ||
expect(response.status).to.equal(200); | ||
expect(response.body).to.have.property('success', true); | ||
expect(response.body).to.have.property('message', 'Standing successfully deleted'); | ||
}); | ||
|
||
it('should return a 404 for an invalid competition code on retrieval', async () => { | ||
const response = await request.get(`/mock/standings/${invalidCompetitionCode}`); | ||
expect(response.status).to.equal(404); | ||
expect(response.body).to.have.property('success', false); | ||
expect(response.body).to.have.property('message', 'Standing not found for the provided competition code'); | ||
}); | ||
|
||
// Additional tests for POST, PUT, and DELETE with invalidCompetitionCode similar to the above test | ||
}); | ||
|