fix
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "matrix-backend",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"type": "commonjs",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"start": "cross-env NODE_ENV=development ts-node-dev --respawn --transpile-only src/index.ts",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { connectToDatabase } from "./database.service";
|
||||
import { UpdateQuery } from "mongoose";
|
||||
import { CreateUserPayload, IUser, SpotifyConfig, UserModel } from "../../db/models/user";
|
||||
|
||||
@@ -9,7 +8,6 @@ export class UserService {
|
||||
|
||||
public static async create(): Promise<UserService> {
|
||||
if (!this._instance) {
|
||||
await connectToDatabase();
|
||||
this._instance = new UserService();
|
||||
}
|
||||
return this._instance;
|
||||
|
||||
@@ -37,14 +37,6 @@ describe("UserService", () => {
|
||||
|
||||
expect(instance1).toBe(instance2);
|
||||
});
|
||||
|
||||
it("should connect to database only on first creation", async () => {
|
||||
|
||||
await UserService.create();
|
||||
await UserService.create();
|
||||
|
||||
expect(mockedConnectToDatabase).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("updateUserById", () => {
|
||||
@@ -57,11 +49,7 @@ describe("UserService", () => {
|
||||
|
||||
const result = await userService.updateUserById(userId, updateData);
|
||||
|
||||
expect(mockedUserModel.findByIdAndUpdate).toHaveBeenCalledWith(
|
||||
userId,
|
||||
updateData,
|
||||
{ new: true }
|
||||
);
|
||||
expect(mockedUserModel.findByIdAndUpdate).toHaveBeenCalledWith(userId, updateData, { new: true });
|
||||
expect(result).toEqual(updatedUser);
|
||||
});
|
||||
|
||||
@@ -177,7 +165,7 @@ describe("UserService", () => {
|
||||
};
|
||||
mockedUserModel.create.mockResolvedValue(createdUserDocument as any);
|
||||
|
||||
const result = await userService.createUser(userData as any)
|
||||
const result = await userService.createUser(userData as any);
|
||||
|
||||
expect(mockedUserModel.create).toHaveBeenCalledWith(userData);
|
||||
expect(result).not.toHaveProperty("password");
|
||||
|
||||
Reference in New Issue
Block a user