-
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
1 parent
df1f926
commit 2455911
Showing
3 changed files
with
162 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const request = require('supertest'); | ||
const app = require('./app'); | ||
|
||
describe('GET /', () => { | ||
test('It should respond with status 200 and render index page', async () => { | ||
const response = await request(app).get('/'); | ||
expect(response.status).toBe(200); | ||
expect(response.text).toContain('index'); | ||
}); | ||
}); | ||
|
||
describe('GET /movies', () => { | ||
test('It should respond with status 200 and render movies page', async () => { | ||
const response = await request(app).get('/movies'); | ||
expect(response.status).toBe(200); | ||
expect(response.text).toContain('movies'); | ||
}); | ||
}); | ||
|
||
// Add more tests for other routes... | ||
|
||
describe('GET /api/character', () => { | ||
test('It should respond with character data', async () => { | ||
const response = await request(app).get('/api/character?character=Spider-Man'); | ||
expect(response.status).toBe(200); | ||
expect(response.body).toHaveProperty('id'); | ||
expect(response.body).toHaveProperty('name', 'Spider-Man'); | ||
// Add more assertions as needed... | ||
}); | ||
|
||
test('It should handle errors gracefully', async () => { | ||
// Mock the axios get method to simulate an error | ||
jest.spyOn(require('axios'), 'get').mockRejectedValue(new Error('Axios error')); | ||
|
||
const response = await request(app).get('/api/character?character=Spider-Man'); | ||
expect(response.status).toBe(500); | ||
expect(response.body).toHaveProperty('error', 'Internal Server Error'); | ||
}); | ||
}); | ||
|
||
// Add more tests for other API endpoints... | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
}, | ||
"devDependencies": { | ||
"jest": "^29.7.0", | ||
"mocha": "^10.4.0" | ||
"mocha": "^10.4.0", | ||
"supertest": "^7.0.0" | ||
} | ||
} |