Added tests on getDefaultCarTag
MODIFY
src/server/rest/v1/router/api/UserRouter.ts
src/server/rest/v1/router/api/UserRouter.ts
@@ -64,7 +64,7 @@ export default class UserRouter {
protected buildRouteUserDefaultCarTag(): void {
this.router.get(`/${ServerRoute.REST_USER_DEFAULT_TAG_CAR}`, async (req: Request, res: Response, next: NextFunction) => {
- req.query.UserID = req.params.id;
+ req.query.ID = req.params.id;
await RouterUtils.handleServerAction(UserService.handleGetUserDefaultTagCar.bind(this), ServerAction.USER_DEFAULT_TAG_CAR, req, res, next);
});
}

MODIFY
test/api/UserTest.ts
test/api/UserTest.ts
@@ -268,6 +268,20 @@ describe('User', function() {
expect(response.data.image).to.be.null; // New users have a null image
});
+ it('Should get the user default car tag', async () => {
+ // Create a tag
+ testData.newTag = Factory.tag.build({ userID: testData.newUser.id });
+ let response = await testData.userService.userApi.createTag(testData.newTag);
+ expect(response.status).to.equal(StatusCodes.CREATED);
+ testData.createdTags.push(testData.newTag);
+ // Retrieve it
+ response = await testData.userService.userApi.getDefaultTagCar(testData.newUser.id);
+ expect(response.status).to.be.eq(StatusCodes.OK);
+ expect(response.data.tag.id).to.be.eq(testData.newTag.id);
+ expect(response.data.car).to.be.undefined;
+ expect(response.data.errorCodes).to.be.empty;
+ });
+
it('Should be able to delete the created user', async () => {
// Delete the created entity
await testData.userService.deleteEntity(

MODIFY
test/api/client/UserApi.ts
test/api/client/UserApi.ts
@@ -78,4 +78,9 @@ export default class UserApi extends CrudApi {
const url = this.buildRestEndpointUrl(ServerRoute.REST_USER_IMAGE, { id: userID });
return await super.read({}, url);
}
+
+ public async getDefaultTagCar(userID: string) {
+ const url = this.buildRestEndpointUrl(ServerRoute.REST_USER_DEFAULT_TAG_CAR, { id: userID });
+ return await super.read({}, url);
+ }
}

Added tests on getDefaultCarTag