-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better error handling added to services, new tests
- Loading branch information
1 parent
f3abaab
commit 92f6ad8
Showing
3 changed files
with
39 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,24 +248,43 @@ describe('PartnerAccessService', () => { | |
}); | ||
describe('getUserTherapySessions', () => { | ||
it('should return user emails with their total therapy sessions available and an associated access code id', async () => { | ||
const repoSpyCreateQueryBuilder = jest.spyOn(repo, 'createQueryBuilder'); | ||
// Mocks the raw results | ||
const mockResults = [ | ||
{ | ||
useremail: '[email protected]', | ||
partneraccesscode: 'ABCDEF', | ||
therapytotal: '2', | ||
}, | ||
{ | ||
useremail: '[email protected]', | ||
partneraccesscode: 'GHIJKL', | ||
therapytotal: '5', | ||
}, | ||
]; | ||
repoSpyCreateQueryBuilder.mockImplementation( | ||
createQueryBuilderMock({ getRawMany: jest.fn().mockResolvedValue(mockResults) }) as never, | ||
); | ||
const userTherapySessions = await service.getUserTherapySessions(); | ||
console.log('user therapy sessionms'); | ||
console.log(userTherapySessions); | ||
// expect(userTherapySessions.length).toBeGreaterThan(0); | ||
expect(userTherapySessions.length).toBeGreaterThan(0); | ||
}); | ||
}); | ||
|
||
describe('updatePartnerAccessTherapyCount', () => { | ||
it('should update the number of therapy sessions remaining on an access code', async () => { | ||
const partnerAccessCode = '123435'; | ||
const therapySessions = 0; | ||
const test = await service.updatePartnerAccessTherapyCount( | ||
partnerAccessCode, | ||
therapySessions, | ||
const repoSpyCreateQueryBuilder = jest.spyOn(repo, 'findOne'); | ||
|
||
// Mocks finding an access code record | ||
const findOneResults = { accessCode: 'ABCSDE', id: '122334' }; | ||
|
||
const sessionFindOneRepoSpy = jest.spyOn(repo, 'createQueryBuilder'); | ||
sessionFindOneRepoSpy.mockImplementation( | ||
createQueryBuilderMock({ findOne: jest.fn().mockResolvedValue(findOneResults) }) as never, | ||
); | ||
console.log(' update user therapy sessionms'); | ||
console.log(test); | ||
// expect(userTherapySessions.length).toBeGreaterThan(0); | ||
|
||
const result = await service.updatePartnerAccessTherapyCount('ABCSDE', 3); | ||
//if an access code exists then update it. | ||
expect(result).toBe('Success'); | ||
}); | ||
}); | ||
}); |
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