generated from agiledev-students-fall2023/generic-project-repository
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #300 from agiledev-students-fall2023/Sprint/4/spik…
…e/299 Sprint/4/spike/299
- Loading branch information
Showing
13 changed files
with
94 additions
and
334 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
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
24 changes: 9 additions & 15 deletions
24
back-end/src/controllers/studentIssueViewDetailsHandler.js
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 was deleted.
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* eslint-disable */ | ||
import chai, { assert } from "chai"; | ||
import IssueModel from "../models/issueModel.js"; | ||
import chaiHttp from "chai-http"; | ||
import server from "../app.js"; | ||
|
||
chai.use(chaiHttp); | ||
|
||
process.env.NODE_ENV = "test"; | ||
|
||
// Integration tests for the adminIssues.js file | ||
describe("Integration Tests for Admin Issue Handler Endpoint", () => { | ||
describe("GET /api/issues/admin/:paramName", () => { | ||
it("should retrieve all issues for a valid admin user", async () => { | ||
const paramName = "admin"; | ||
const res = await chai | ||
.request(server) | ||
.get(`/api/issues/admin/${paramName}`); | ||
// Check that the response is correct | ||
assert.equal(res.status, 200); | ||
// Check that the response is an array | ||
assert.isArray(res.body); | ||
// Check that the response is the same length as the number of issues | ||
const userIssues = await IssueModel.find({ "departments": paramName }); | ||
// Check that the response is the same length as the number of issues of that user | ||
assert.equal(res.body.length, userIssues.length); | ||
}); | ||
|
||
it("should handle errors gracefully for an invalid admin user", async () => { | ||
const paramName = "invalid"; | ||
const res = await chai | ||
.request(server) | ||
.get(`/api/issues/admin/${paramName}`); | ||
assert.equal(res.status, 200); | ||
assert.deepEqual(res.body, []); | ||
}); | ||
}); | ||
}); | ||
/* eslint-enable */ |
This file was deleted.
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
Oops, something went wrong.