-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(charts): objective charts now returns correct values (#790)
- Loading branch information
1 parent
46236be
commit c8e7b43
Showing
2 changed files
with
44 additions
and
3 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,39 @@ | ||
const Stats = require('../../src/routes/stats'); | ||
|
||
describe('routes > stats', () => { | ||
describe('.get', () => { | ||
it('should return a value for objective chart', async () => { | ||
expect.assertions(1); | ||
|
||
const app = {}; | ||
const model = { name: 'book' }; | ||
|
||
class FakeValueStatGetter { | ||
perform = jest.fn(async () => ({ value: { countCurrent: 5 } })) | ||
} | ||
|
||
const Implementation = { | ||
getModelName: jest.fn(() => 'books'), | ||
ValueStatGetter: FakeValueStatGetter, | ||
}; | ||
|
||
const next = jest.fn(); | ||
const req = { | ||
params: { recordId: '1' }, | ||
query: { timezone: 'Europe/Paris' }, | ||
user: { renderingId: 1 }, | ||
body: { type: 'Objective' }, | ||
}; | ||
const res = { | ||
send: jest.fn(), | ||
}; | ||
|
||
const subject = new Stats(app, model, Implementation); | ||
await subject.get(req, res, next); | ||
|
||
const resMockParameters = res.send.mock.calls[0][0]; | ||
|
||
expect(resMockParameters.data.attributes.value.value).toStrictEqual(5); | ||
}); | ||
}); | ||
}); |