test(repositories): fix mock implementation of thenable query builders in repository tests
Some checks failed
CI/CD Pipeline / Valider backend (push) Failing after 1m13s
CI/CD Pipeline / Valider frontend (push) Successful in 1m40s
CI/CD Pipeline / Valider documentation (push) Successful in 1m43s
CI/CD Pipeline / Déploiement en Production (push) Has been skipped

This commit is contained in:
Mathis HERRIOT
2026-01-20 14:04:57 +01:00
parent bad2caef08
commit 2291cc8afb
4 changed files with 32 additions and 16 deletions

View File

@@ -20,10 +20,14 @@ describe("ApiKeysRepository", () => {
};
const wrapWithThen = (obj: any) => {
obj.then = function (onFulfilled: any) {
const result = this.execute();
return Promise.resolve(result).then(onFulfilled);
};
// biome-ignore lint/suspicious/noThenProperty: Necessary to mock Drizzle's awaitable query builder
Object.defineProperty(obj, "then", {
value: function (onFulfilled: any) {
const result = this.execute();
return Promise.resolve(result).then(onFulfilled);
},
configurable: true,
});
return obj;
};
wrapWithThen(mockDb);

View File

@@ -21,10 +21,14 @@ describe("CategoriesRepository", () => {
};
const wrapWithThen = (obj: any) => {
obj.then = function (onFulfilled: any) {
const result = this.execute();
return Promise.resolve(result).then(onFulfilled);
};
// biome-ignore lint/suspicious/noThenProperty: Necessary to mock Drizzle's awaitable query builder
Object.defineProperty(obj, "then", {
value: function (onFulfilled: any) {
const result = this.execute();
return Promise.resolve(result).then(onFulfilled);
},
configurable: true,
});
return obj;
};
wrapWithThen(mockDb);

View File

@@ -20,10 +20,14 @@ describe("FavoritesRepository", () => {
};
const wrapWithThen = (obj: any) => {
obj.then = function (onFulfilled: any) {
const result = this.execute();
return Promise.resolve(result).then(onFulfilled);
};
// biome-ignore lint/suspicious/noThenProperty: Necessary to mock Drizzle's awaitable query builder
Object.defineProperty(obj, "then", {
value: function (onFulfilled: any) {
const result = this.execute();
return Promise.resolve(result).then(onFulfilled);
},
configurable: true,
});
return obj;
};
wrapWithThen(mockDb);

View File

@@ -22,10 +22,14 @@ describe("ReportsRepository", () => {
};
const wrapWithThen = (obj: any) => {
obj.then = function (onFulfilled: any) {
const result = this.execute();
return Promise.resolve(result).then(onFulfilled);
};
// biome-ignore lint/suspicious/noThenProperty: Necessary to mock Drizzle's awaitable query builder
Object.defineProperty(obj, "then", {
value: function (onFulfilled: any) {
const result = this.execute();
return Promise.resolve(result).then(onFulfilled);
},
configurable: true,
});
return obj;
};
wrapWithThen(mockDb);