From 4363d69a56efff61084eebee6eeb912763b5e34c Mon Sep 17 00:00:00 2001 From: Luke Watts Date: Sun, 5 May 2024 09:44:11 +0200 Subject: [PATCH] test: switch from fixture to factory (#3495) Using factories allow for more flexibility in generating data, as they can dynamically create the necessary data for each test case. This makes it easier to modify the data or add new variations without affecting multiple tests, unlike with static fixtures which can introduce coupling between tests. --- src/pages/Howto/howto.service.test.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pages/Howto/howto.service.test.ts b/src/pages/Howto/howto.service.test.ts index 3896c81291..207c3c33c1 100644 --- a/src/pages/Howto/howto.service.test.ts +++ b/src/pages/Howto/howto.service.test.ts @@ -1,11 +1,10 @@ import '@testing-library/jest-dom' -import { MOCKS } from 'oa-shared' +import { UserRole } from 'oa-shared/models' +import { FactoryUser } from 'src/test/factories/User' import { exportedForTesting } from './howto.service' -import type { IUser } from 'src/models' - const mockWhere = jest.fn() const mockOrderBy = jest.fn() const mockLimit = jest.fn() @@ -129,7 +128,9 @@ describe('howtos.search', () => { ['test'], '', 'Newest', - MOCKS.data.users.admin as unknown as IUser, + FactoryUser({ + userRoles: [UserRole.ADMIN], + }), undefined, )