Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EW-893 fixing unit test
Browse files Browse the repository at this point in the history
psachmann committed Jun 10, 2024
1 parent 4ed2937 commit 85998e1
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions apps/server/src/modules/account/api/test/account.api.spec.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { EntityManager } from '@mikro-orm/mongodb';
import { ServerTestModule } from '@modules/server/server.module';
import { INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { User } from '@shared/domain/entity';
import { Permission, RoleName } from '@shared/domain/interface';
import { TestApiClient, cleanupCollections, roleFactory, schoolEntityFactory, userFactory } from '@shared/testing';
import { ServerTestModule } from '@modules/server/server.module';
import { AccountEntity } from '../../domain/entity/account.entity';
import { accountFactory } from '../../testing';
import {
AccountByIdBodyParams,
AccountSearchQueryParams,
AccountSearchType,
PatchMyAccountParams,
PatchMyPasswordParams,
} from '../dto';
import { AccountEntity } from '../../domain/entity/account.entity';
import { accountFactory } from '../../testing';

describe('Account Controller (API)', () => {
const basePath = '/account';
@@ -495,8 +495,8 @@ describe('Account Controller (API)', () => {
const studentUser = userFactory.buildWithId({ school, roles: [studentRoles] });
const superheroUser = userFactory.buildWithId({ roles: [superheroRoles] });

const studentAccount = mapUserToAccount(studentUser);
const superheroAccount = mapUserToAccount(superheroUser);
const studentAccount = accountFactory.withUser(studentUser).build();
const superheroAccount = accountFactory.withUser(superheroUser).build();

em.persist(school);
em.persist([studentRoles, superheroRoles]);
6 changes: 3 additions & 3 deletions apps/server/src/modules/account/testing/account.factory.ts
Original file line number Diff line number Diff line change
@@ -3,9 +3,9 @@ import { User } from '@shared/domain/entity';
import { EntityId } from '@shared/domain/types';

import { ObjectId } from '@mikro-orm/mongodb';
import { DeepPartial } from 'fishery';
import { AccountEntity, IdmAccountProperties } from '@src/modules/account/domain/entity/account.entity';
import { BaseFactory } from '@shared/testing/factory/base.factory';
import { AccountEntity, IdmAccountProperties } from '@src/modules/account/domain/entity/account.entity';
import { DeepPartial } from 'fishery';

export const defaultTestPassword = 'DummyPasswd!1';
export const defaultTestPasswordHash = '$2a$10$/DsztV5o6P5piW2eWJsxw.4nHovmJGBA.QNwiTmuZ/uvUc40b.Uhu';
@@ -58,7 +58,7 @@ class AccountFactory extends BaseFactory<AccountEntity, IdmAccountProperties> {
// !!! important username should not be contain a space !!!
export const accountFactory = AccountFactory.define(AccountEntity, ({ sequence }) => {
return {
username: `account${sequence}`,
username: `account#${sequence}@example.tld`,
password: defaultTestPasswordHash,
userId: new ObjectId(),
};

0 comments on commit 85998e1

Please sign in to comment.