NathanaelAma / LoRDeckTrackerServer

Lines not covered in tests TCV-001
Coverage
Critical
2 months ago3 months old
Lines not covered in tests
 87      if (findUser && findUser.username !== userName) throw new HttpException(409, `This email ${userData.email} already exists`);
 88    }
 89
 90    if (userData.password) { 91      const hashedPassword = await hash(userData.password, 10); 92      userData = { 93        ...userData, 94        password: hashedPassword, 95        updated_at: new Date().toISOString(), 96      }; 97    } 98 99    const updateUserByUserName: User = await this.users.findOneAndUpdate({ username: userName }, { userData });100    if (!updateUserByUserName) throw new HttpException(409, "User doesn't exist");101102    return updateUserByUserName;103  }
104
105  /**
Lines not covered in tests
 27   * @throws {HttpException} if the userId is empty or if the user doesn't exist.
 28   */
 29  public async findUserById(userId: string): Promise<User> {
 30    if (isEmpty(userId)) throw new HttpException(400, 'UserId is empty'); 31 32    const findUser: User = await this.users.findOne({ _id: userId }); 33    if (!findUser) throw new HttpException(409, "User doesn't exist"); 34 35    return findUser; 36  }
 37
 38  /**
Lines not covered in tests
 98
 99      res.status(200).json({ data: deleteUserData, message: 'deleted' });
100    } catch (error) {
101      next(error);102    }
103  };
104}
Lines not covered in tests
 80      const userData: UserDto = req.body;
 81      const updateUserData: User = await this.userService.updateUser(userName, userData);
 82
 83      res.status(200).json({ data: updateUserData, message: 'updated' }); 84    } catch (error) {
 85      next(error);
 86    }
Lines not covered in tests
 64
 65      res.status(201).json({ data: createUserData, message: 'created' });
 66    } catch (error) {
 67      next(error); 68    }
 69  };
 70