From bd86a6951ca60ee0bf6486ad94d75142f1225c4a Mon Sep 17 00:00:00 2001 From: jlenon7 Date: Mon, 29 Apr 2024 14:01:43 +0100 Subject: [PATCH] test(config): disable validation --- package-lock.json | 8 ++++---- package.json | 2 +- src/config/database.ts | 6 +++++- tests/unit/user.service.test.ts | 9 +-------- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 50c3a3c..32cb0be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@athenna/common": "^4.36.0", "@athenna/config": "^4.20.0", "@athenna/core": "^4.37.0", - "@athenna/database": "^4.48.0", + "@athenna/database": "^4.49.0", "@athenna/http": "^4.32.0", "@athenna/ioc": "^4.19.0", "@athenna/logger": "^4.20.0", @@ -219,9 +219,9 @@ } }, "node_modules/@athenna/database": { - "version": "4.48.0", - "resolved": "https://registry.npmjs.org/@athenna/database/-/database-4.48.0.tgz", - "integrity": "sha512-5GxLHhYnQExW5uaKzQxboXASyBNx3WMMfsGxc+N0T8gJcEENaliWqThCrW0RzbknXCtiqRMD3aFnl1RdHld4PQ==", + "version": "4.49.0", + "resolved": "https://registry.npmjs.org/@athenna/database/-/database-4.49.0.tgz", + "integrity": "sha512-D2yKop9D1kvs4LGuzWciNeqispEW64WU4x1gYdH1X+LFOkfMCAnHIKys+0zvoL/SqXAJ/qqWwwlYXiUHpoxJaw==", "dependencies": { "@faker-js/faker": "^8.4.0", "fast-deep-equal": "^3.1.3" diff --git a/package.json b/package.json index dda7bf7..f31a11c 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "@athenna/common": "^4.36.0", "@athenna/config": "^4.20.0", "@athenna/core": "^4.37.0", - "@athenna/database": "^4.48.0", + "@athenna/database": "^4.49.0", "@athenna/http": "^4.32.0", "@athenna/ioc": "^4.19.0", "@athenna/logger": "^4.20.0", diff --git a/src/config/database.ts b/src/config/database.ts index 20918fa..b7e0ec5 100644 --- a/src/config/database.ts +++ b/src/config/database.ts @@ -69,7 +69,11 @@ export default { fake: { driver: 'fake', - validations: false + validations: { + isToSetAttributes: true, + isToValidateUnique: false, + isToValidateNullable: false + } } } } diff --git a/tests/unit/user.service.test.ts b/tests/unit/user.service.test.ts index 8402c25..271923c 100644 --- a/tests/unit/user.service.test.ts +++ b/tests/unit/user.service.test.ts @@ -39,12 +39,7 @@ export default class UserServiceTest { } const fakeUser = await User.factory().count(1).make(userToCreate) - Mock.when(Database.driver, 'find') - .onFirstCall() - .resolve(undefined) - .onSecondCall() - .resolve({ id: 1, name: RoleEnum.CUSTOMER }) - + Mock.when(Database.driver, 'find').resolve({ id: 1, name: RoleEnum.CUSTOMER }) Mock.when(Database.driver, 'createMany').resolve([fakeUser]) const user = await new UserService().create(userToCreate) @@ -116,7 +111,6 @@ export default class UserServiceTest { } const fakeUser = await User.factory().count(1).make(userToUpdate) - Mock.when(Database.driver, 'find').resolve(undefined) Mock.when(Database.driver, 'update').resolve(fakeUser) await new UserService().update(1, userToUpdate) @@ -133,7 +127,6 @@ export default class UserServiceTest { } const fakeUser = await User.factory().count(1).make(userToUpdate) - Mock.when(Database.driver, 'find').resolve(undefined) Mock.when(Database.driver, 'update').resolve(fakeUser) await new UserService().update(1, userToUpdate)