Skip to content

Commit

Permalink
fixing unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
LawrenceLau2020 committed Aug 2, 2024
1 parent 621a8a8 commit f2c5b0a
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { ImportResult } from '@/typeorm/Entities/ImportResult';
import { Parcel } from '@/typeorm/Entities/Parcel';
import { ParcelEvaluation } from '@/typeorm/Entities/ParcelEvaluation';
import { ParcelFiscal } from '@/typeorm/Entities/ParcelFiscal';
import { ProjectProperty } from '@/typeorm/Entities/ProjectProperty';
import { ProjectStatus } from '@/typeorm/Entities/ProjectStatus';
import { PropertyClassification } from '@/typeorm/Entities/PropertyClassification';
import { User } from '@/typeorm/Entities/User';
import { MapProperties } from '@/typeorm/Entities/views/MapPropertiesView';
Expand All @@ -38,6 +40,8 @@ import {
produceBuildingEvaluation,
produceBuildingFiscal,
produceSSO,
produceProjectStatus,
produceProjectProperty,
} from 'tests/testUtils/factories';
import { DeepPartial, EntityTarget, ObjectLiteral } from 'typeorm';
import xlsx, { WorkSheet } from 'xlsx';
Expand Down Expand Up @@ -82,6 +86,46 @@ const _propertyUnionCreateQueryBuilder: any = {
getManyAndCount: () => [[producePropertyUnion()], 1],
};

const _projectStatusCreateQueryBuilder: any = {
select: () => _projectStatusCreateQueryBuilder,
leftJoinAndSelect: () => _projectStatusCreateQueryBuilder,
where: () => _projectStatusCreateQueryBuilder,
orWhere: () => _projectStatusCreateQueryBuilder,
andWhere: () => _projectStatusCreateQueryBuilder,
take: () => _projectStatusCreateQueryBuilder,
skip: () => _projectStatusCreateQueryBuilder,
orderBy: () => _projectStatusCreateQueryBuilder,
getMany: () => [produceProjectStatus()],
};

const _projectPropertyCreateQueryBuilder: any = {
select: () => _projectPropertyCreateQueryBuilder,
leftJoinAndSelect: () => _projectPropertyCreateQueryBuilder,
where: () => _projectPropertyCreateQueryBuilder,
orWhere: () => _projectPropertyCreateQueryBuilder,
andWhere: () => _projectPropertyCreateQueryBuilder,
take: () => _projectPropertyCreateQueryBuilder,
skip: () => _projectPropertyCreateQueryBuilder,
orderBy: () => _projectPropertyCreateQueryBuilder,
getMany: () => [produceProjectProperty()],
};

jest
.spyOn(AppDataSource.getRepository(ProjectProperty), 'createQueryBuilder')
.mockImplementation(() => _projectPropertyCreateQueryBuilder);

jest
.spyOn(AppDataSource.getRepository(ProjectProperty), 'find')
.mockImplementation(async () => [produceProjectProperty()]);

jest
.spyOn(AppDataSource.getRepository(ProjectStatus), 'createQueryBuilder')
.mockImplementation(() => _projectStatusCreateQueryBuilder);

jest
.spyOn(AppDataSource.getRepository(ProjectStatus), 'find')
.mockImplementation(async () => [produceProjectStatus()]);

jest
.spyOn(AppDataSource.getRepository(Parcel), 'createQueryBuilder')
.mockImplementation(() => _parcelsCreateQueryBuilder);
Expand Down

0 comments on commit f2c5b0a

Please sign in to comment.