Skip to content

Commit

Permalink
chore: Replace actual messages with constants for easily maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
pankajjs committed Jan 7, 2025
1 parent 5f7436c commit 024dc63
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions test/integration/onboardingExtension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import {
REQUEST_ALREADY_PENDING,
REQUEST_STATE, REQUEST_TYPE,
ONBOARDING_REQUEST_CREATED_SUCCESSFULLY,
UNAUTHORIZED_TO_CREATE_ONBOARDING_EXTENSION_REQUEST
UNAUTHORIZED_TO_CREATE_ONBOARDING_EXTENSION_REQUEST,
INVALID_REQUEST_DEADLINE,

Check failure on line 14 in test/integration/onboardingExtension.test.ts

View workflow job for this annotation

GitHub Actions / build (20.11.x)

Module '"../../constants/requests"' has no exported member 'INVALID_REQUEST_DEADLINE'.

Check failure on line 14 in test/integration/onboardingExtension.test.ts

View workflow job for this annotation

GitHub Actions / build (20.11.x)

Module '"../../constants/requests"' has no exported member 'INVALID_REQUEST_DEADLINE'.
PENDING_REQUEST_UPDATED,

Check failure on line 15 in test/integration/onboardingExtension.test.ts

View workflow job for this annotation

GitHub Actions / build (20.11.x)

Module '"../../constants/requests"' has no exported member 'PENDING_REQUEST_UPDATED'.

Check failure on line 15 in test/integration/onboardingExtension.test.ts

View workflow job for this annotation

GitHub Actions / build (20.11.x)

Module '"../../constants/requests"' has no exported member 'PENDING_REQUEST_UPDATED'.
REQUEST_UPDATED_SUCCESSFULLY,

Check failure on line 16 in test/integration/onboardingExtension.test.ts

View workflow job for this annotation

GitHub Actions / build (20.11.x)

'"../../constants/requests"' has no exported member named 'REQUEST_UPDATED_SUCCESSFULLY'. Did you mean 'REQUEST_CREATED_SUCCESSFULLY'?

Check failure on line 16 in test/integration/onboardingExtension.test.ts

View workflow job for this annotation

GitHub Actions / build (20.11.x)

'"../../constants/requests"' has no exported member named 'REQUEST_UPDATED_SUCCESSFULLY'. Did you mean 'REQUEST_CREATED_SUCCESSFULLY'?
INVALID_REQUEST_TYPE,

Check failure on line 17 in test/integration/onboardingExtension.test.ts

View workflow job for this annotation

GitHub Actions / build (20.11.x)

Module '"../../constants/requests"' has no exported member 'INVALID_REQUEST_TYPE'.

Check failure on line 17 in test/integration/onboardingExtension.test.ts

View workflow job for this annotation

GitHub Actions / build (20.11.x)

Module '"../../constants/requests"' has no exported member 'INVALID_REQUEST_TYPE'.
REQUEST_DOES_NOT_EXIST
} from "../../constants/requests";
const { generateToken } = require("../../test/utils/generateBotToken");
import app from "../../server";
Expand Down Expand Up @@ -349,7 +354,7 @@ describe("/requests Onboarding Extension", () => {
chai.request(app)
.patch(patchEndpoint)
.set("authorization", `Bearer ${authToken}`)
.send({...body, type: REQUEST_TYPE.OOO})
.send({...body, type: "<invalid-type>"})
.end((err, res) => {
if(err) return done(err);
expect(res.statusCode).to.equal(400);
Expand Down Expand Up @@ -421,7 +426,7 @@ describe("/requests Onboarding Extension", () => {
.end((err, res) => {
if (err) return done(err);
expect(res.statusCode).to.equal(404);
expect(res.body.message).to.equal("Request does not exist");
expect(res.body.message).to.equal(REQUEST_DOES_NOT_EXIST);
expect(res.body.error).to.equal("Not Found");
done();
})
Expand All @@ -435,7 +440,7 @@ describe("/requests Onboarding Extension", () => {
.end((err, res) => {
if (err) return done(err);
expect(res.statusCode).to.equal(400);
expect(res.body.message).to.equal("Invalid request type");
expect(res.body.message).to.equal(INVALID_REQUEST_TYPE);
expect(res.body.error).to.equal("Bad Request");
done();
})
Expand All @@ -449,7 +454,7 @@ describe("/requests Onboarding Extension", () => {
.end((err, res) => {
if (err) return done(err);
expect(res.statusCode).to.equal(400);
expect(res.body.message).to.equal("Request state is not pending");
expect(res.body.message).to.equal(PENDING_REQUEST_UPDATED);
expect(res.body.error).to.equal("Bad Request");
done();
})
Expand All @@ -463,7 +468,7 @@ describe("/requests Onboarding Extension", () => {
.end((err, res) => {
if (err) return done(err);
expect(res.statusCode).to.equal(400);
expect(res.body.message).to.equal("Request new deadline must be greater than old deadline.");
expect(res.body.message).to.equal(INVALID_REQUEST_DEADLINE);
expect(res.body.error).to.equal("Bad Request");
done();
})
Expand All @@ -477,7 +482,7 @@ describe("/requests Onboarding Extension", () => {
.end((err, res)=>{
if(err) return done(err);
expect(res.statusCode).to.equal(200);
expect(res.body.message).to.equal("Request updated successfully");
expect(res.body.message).to.equal(REQUEST_UPDATED_SUCCESSFULLY);
expect(res.body.data.id).to.equal(latestValidExtension.id);
expect(res.body.data.newEndsOn).to.equal(body.newEndsOn)
done();
Expand Down

0 comments on commit 024dc63

Please sign in to comment.