Skip to content

Commit

Permalink
test: switch from fixture to factory (#3495)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thisislawatts committed May 5, 2024
1 parent 2d61c4a commit 4363d69
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/pages/Howto/howto.service.test.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -129,7 +128,9 @@ describe('howtos.search', () => {
['test'],
'',
'Newest',
MOCKS.data.users.admin as unknown as IUser,
FactoryUser({
userRoles: [UserRole.ADMIN],
}),
undefined,
)

Expand Down

0 comments on commit 4363d69

Please sign in to comment.