-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove PupilFeedback model dependency from the controller (#335)
* Remove PupilFeedback model dependency from the controller * updating test as its looking for the wrong pupil
- Loading branch information
1 parent
9bddaa2
commit 2f3f19a
Showing
6 changed files
with
89 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict' | ||
|
||
const PupilFeedback = require('../../models/pupil-feedback') | ||
const pupilFeedbackDataService = { | ||
|
||
/** | ||
* CREATE a new pupil-feedback record | ||
* @param data | ||
* @return {Promise<*>} | ||
*/ | ||
create: async (data) => { | ||
const pf = new PupilFeedback(data) | ||
await pf.save() | ||
return pf.toObject() | ||
} | ||
} | ||
|
||
module.exports = pupilFeedbackDataService |
File renamed without changes.
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
36 changes: 36 additions & 0 deletions
36
admin/spec/service/data-access/pupil-feedback.data.service.spec.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict' | ||
/* global describe, beforeEach, afterEach, it, expect */ | ||
|
||
const proxyquire = require('proxyquire').noCallThru() | ||
const sinon = require('sinon') | ||
require('sinon-mongoose') | ||
|
||
const PupilFeedback = require('../../../models/pupil-feedback') | ||
// const pupilFeedback = require('../../mocks/pupil-feedback') | ||
|
||
describe('check.data.service', () => { | ||
let service, sandbox | ||
|
||
beforeEach(() => { | ||
sandbox = sinon.sandbox.create() | ||
}) | ||
|
||
afterEach(() => sandbox.restore()) | ||
|
||
describe('#create', () => { | ||
let mock | ||
|
||
beforeEach(() => { | ||
mock = sandbox.mock(PupilFeedback.prototype).expects('save') | ||
service = proxyquire('../../../services/data-access/pupil-feedback.data.service', { | ||
'../../models/pupil-feedback': PupilFeedback | ||
}) | ||
}) | ||
|
||
it('makes the expected calls', async (done) => { | ||
await service.create({test: 'property'}) | ||
expect(mock.verify()).toBe(true) | ||
done() | ||
}) | ||
}) | ||
}) |
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