diff --git a/controllers/opportunity/index.js b/controllers/opportunity/index.js index 5f74aae..272993b 100644 --- a/controllers/opportunity/index.js +++ b/controllers/opportunity/index.js @@ -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, diff --git a/managers/opportunity/index.js b/managers/opportunity/index.js index ac0aee6..66fbff1 100644 --- a/managers/opportunity/index.js +++ b/managers/opportunity/index.js @@ -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'); diff --git a/package-lock.json b/package-lock.json index b87f0e1..24d8205 100644 --- a/package-lock.json +++ b/package-lock.json @@ -552,6 +552,7 @@ "dependencies": { "anymatch": "~3.1.1", "braces": "~3.0.2", + "fsevents": "~2.3.1", "glob-parent": "~5.1.0", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", @@ -2055,7 +2056,8 @@ "bson": "^1.1.4", "denque": "^1.4.1", "require_optional": "^1.0.1", - "safe-buffer": "^5.1.2" + "safe-buffer": "^5.1.2", + "saslprep": "^1.0.0" }, "engines": { "node": ">=4" @@ -3566,6 +3568,7 @@ "resolved": "https://registry.npmjs.org/z-schema/-/z-schema-4.2.3.tgz", "integrity": "sha512-zkvK/9TC6p38IwcrbnT3ul9in1UX4cm1y/VZSs4GHKIiDCrlafc+YQBgQBUdDXLAoZHf2qvQ7gJJOo6yT1LH6A==", "dependencies": { + "commander": "^2.7.1", "lodash.get": "^4.4.2", "lodash.isequal": "^4.5.0", "validator": "^12.0.0" diff --git a/services/opportunity/index.js b/services/opportunity/index.js index 89519f7..bcc3b76 100644 --- a/services/opportunity/index.js +++ b/services/opportunity/index.js @@ -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'); diff --git a/tests/fakedata.js b/tests/fakedata.js index 98554e0..9fcba4c 100644 --- a/tests/fakedata.js +++ b/tests/fakedata.js @@ -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; diff --git a/tests/managers/opportunity-test.js b/tests/managers/opportunity-test.js index 6155984..1ff8b89 100644 --- a/tests/managers/opportunity-test.js +++ b/tests/managers/opportunity-test.js @@ -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 () { @@ -111,6 +112,14 @@ describe('OpportunityManager', function () { queryObject, updatingobject ); + + 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(