Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions controllers/opportunity/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class opportunityController {
let opportunity_id = req.params.opportunity_id;
let queryObject = { _id: opportunity_id };
let updatingprops = req.body;

try {
let updatedOpportunity = await this.opportunityService.updateOpportunity(
queryObject,
Expand Down
4 changes: 3 additions & 1 deletion managers/opportunity/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ class opportunityManager {

async deleteOpportunity(opportunity_id) {
try {
let deletedDocument = await this.opportunity.findByIdAndRemove(opportunity_id);
let deletedDocument = await this.opportunity.findByIdAndRemove(
opportunity_id
);
return deletedDocument;
} catch (err) {
console.log('ERROR IN deleteOpportunity MANAGER');
Expand Down
5 changes: 4 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion services/opportunity/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ class opportunityService {

async deleteOpportunity(opportunity_id) {
try {
let deletedDocument = await this.opportunityManager.deleteOpportunity(opportunity_id);
let deletedDocument = await this.opportunityManager.deleteOpportunity(
opportunity_id
);
return deletedDocument;
} catch (err) {
console.log('ERROR IN deleteOpportunity Service');
Expand Down
1 change: 1 addition & 0 deletions tests/fakedata.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ let stubValue = {
opportunityURL: faker.internet.url(),
createdAt: faker.date.past(),
updatedAt: faker.date.past(),
organisationLogoURL: faker.internet.url(),
};

export default stubValue;
11 changes: 10 additions & 1 deletion tests/managers/opportunity-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { expect } from 'chai';
import { assert, expect } from 'chai';
import sinon from 'sinon';
import stubValue from '../fakedata.js';
import Opportunity from '../../models/opportunity.js';
import OpportunityManager from '../../managers/opportunity/index.js';
import opportunity from '../../models/opportunity.js';

describe('OpportunityManager', function () {
describe('createOpportunity', function () {
Expand Down Expand Up @@ -111,6 +112,14 @@ describe('OpportunityManager', function () {
queryObject,
updatingobject
);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kashish0423 Test the API on postman yourself, see what it does when

  1. 12-bit incorrect id is passed
  2. lesser or greater than 12 bit id is passed

See the API Response in both cases and write the test cases accordingly.

Also, the test updateOpportunity has to be updated with more test cases, you wont have multiple describe blocks, instead multiple it blocks.
In tests/managers/opportunity-test.js, tests/services/opportunity-test.js , tests/controllers/opportunity-test.js, the test describe('updateOpportunity is to be updated with more test cases i.e more it blocks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay mam on it , I will try to get it done asap

describe('', function () {
it.only('The test will fail if id is not present in the DB', function () {
expect(stubValue._id.length === 36).to.be.true; // length of id
expect(updatedOpportunity._id === stubValue._id).to.be.true;
});
});

expect(stub.calledOnce).to.be.true;

expect(updatedOpportunity.opportunityTitle).to.equal(
Expand Down