Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server
1 result
Show changes
Showing
with 76 additions and 137 deletions
......@@ -18,10 +18,6 @@ export class OnlineMediationService {
private readonly mailerService: MailerService
) {}
/**
* @param newMediation
* @returns {Promise<OnlineMediationDocument>}
*/
public async create(newMediation: OnlineMediationDto): Promise<IOnlineMediation> {
try {
newMediation.surname = newMediation.surname.toUpperCase();
......@@ -32,9 +28,6 @@ export class OnlineMediationService {
}
}
/**
* @returns {Promise<OnlineMediationDocument[]>}
*/
public async getAll(): Promise<IOnlineMediation[]> {
return this.OnlineMediationModel.find().sort({ NamedNodeMap: 1 }).exec();
}
......
import { HttpModule, HttpService } from '@nestjs/axios';
import { Test, TestingModule } from '@nestjs/testing';
import { Test } from '@nestjs/testing';
import { AxiosResponse } from 'axios';
import { of } from 'rxjs';
import { ConfigurationModule } from '../configuration/configuration.module';
......@@ -12,7 +12,7 @@ describe('PagesController', () => {
get: jest.fn(),
};
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
const module = await Test.createTestingModule({
imports: [ConfigurationModule, HttpModule],
providers: [
{
......
import { ApiProperty } from '@nestjs/swagger';
export class PersonalOfferDto {
/** accompaniments **/
/** accompaniments */
@ApiProperty({
description: 'List of personal offers categories',
type: [{}],
......
import { Test, TestingModule } from '@nestjs/testing';
import { Test } from '@nestjs/testing';
import {
createPersonalOffersDtoDataMock,
personalOffersDataMock,
......@@ -20,7 +20,7 @@ describe('PersonalOffersController', () => {
let personalOffersController: PersonalOffersController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
const module = await Test.createTestingModule({
controllers: [PersonalOffersController],
providers: [
{
......@@ -57,7 +57,6 @@ describe('PersonalOffersController', () => {
it('should get personal offer does not exist', async () => {
try {
await personalOffersController.find('abcd');
// Fail test if above expression doesn't throw anything.
expect(true).toBe(false);
} catch (e) {
expect(e.message).toBe('Personal offer does not exist');
......@@ -71,7 +70,6 @@ describe('PersonalOffersController', () => {
const req = { user: { _id: '6036721022462b001334c4bb' } };
try {
await personalOffersController.create(req, createPersonalOffersDtoDataMock[3]);
// Fail test if above expression doesn't throw anything.
expect(true).toBe(false);
} catch (e) {
expect(e.message).toBe('Empty personal offer');
......@@ -88,7 +86,6 @@ describe('PersonalOffersController', () => {
const req = { user: { _id: '6036721022462b001334c4bb' } };
try {
await personalOffersController.create(req, createPersonalOffersDtoDataMock[1]);
// Fail test if above expression doesn't throw anything.
expect(true).toBe(false);
} catch (e) {
expect(e.message).toBe('Personal offer already exist in the structure');
......@@ -99,7 +96,6 @@ describe('PersonalOffersController', () => {
const req = { user: { _id: '6036721022462b001334c4bb' } };
try {
await personalOffersController.create(req, createPersonalOffersDtoDataMock[2]);
// Fail test if above expression doesn't throw anything.
expect(true).toBe(false);
} catch (e) {
expect(e.message).toBe('Structure not found for the personal offer attachment');
......@@ -110,7 +106,6 @@ describe('PersonalOffersController', () => {
const req = { user: { _id: 'unIdQuiExistePasTropTrop' } };
try {
await personalOffersController.create(req, createPersonalOffersDtoDataMock[0]);
// Fail test if above expression doesn't throw anything.
expect(true).toBe(false);
} catch (e) {
expect(e.message).toBe('User not found for the personal offer attachment');
......@@ -128,7 +123,6 @@ describe('PersonalOffersController', () => {
it('should get invalid personal offer id', async () => {
try {
await personalOffersController.update('abcd', updatePersonalOffersDtoDataMock[1]);
// Fail test if above expression doesn't throw anything.
expect(true).toBe(false);
} catch (e) {
expect(e.message).toBe('Invalid personal offer id for update');
......@@ -144,7 +138,6 @@ describe('PersonalOffersController', () => {
it('should get invalid personal offer id', async () => {
try {
await personalOffersController.delete('abcd');
// Fail test if above expression doesn't throw anything.
expect(true).toBe(false);
} catch (e) {
expect(e.message).toBe('Invalid personal offer id for deletion');
......
......@@ -20,7 +20,7 @@ import { UsersService } from '../users/services/users.service';
import { CreatePersonalOfferDto } from './dto/create-personal-offer.dto';
import { PersonalOfferDto } from './dto/personal-offer.dto';
import { PersonalOffersService } from './personal-offers.service';
import { PersonalOfferDocument } from './schemas/personal-offer.schema';
import { PersonalOffer, PersonalOfferDocument } from './schemas/personal-offer.schema';
import { Types } from 'mongoose';
@ApiTags('personnal-offers')
......@@ -34,19 +34,15 @@ export class PersonalOffersController {
/**
* Return personal offer of given id.
* @param id
* @returns {PersonalOffer} Personal offer
*/
@Get(':id')
@ApiParam({ name: 'id', type: String, required: true })
public async find(@Param('id') id: string) {
public async find(@Param('id') id: string): Promise<PersonalOffer> {
return this.personalOffersService.findOne(id);
}
/**
* Create and return a personal offer.
* @param createPersonalOfferDto
* @returns {PersonalOffer} created personal offer
*/
@Post()
@ApiBody({ type: CreatePersonalOfferDto, required: true })
......@@ -74,9 +70,6 @@ export class PersonalOffersController {
/**
* Update and return a personal offer.
* @param id - id of the personal offer to update
* @param updatePersonalOfferDto - personal offer data to update
* @returns {PersonalOffer} Updated personal offer
*/
@Put(':id')
@ApiParam({ name: 'id', type: String, required: true })
......@@ -91,8 +84,6 @@ export class PersonalOffersController {
/**
* Delete and return a personal offer.
* @param id - id of the personal offer to delete
* @returns {PersonalOffer} Deleted personal offer
*/
@Delete(':id')
@ApiParam({ name: 'id', type: String, required: true })
......
import { getModelToken } from '@nestjs/mongoose';
import { Test, TestingModule } from '@nestjs/testing';
import { Test } from '@nestjs/testing';
import {
createPersonalOffersDtoDataMock,
personalOffersDataMock,
......@@ -23,7 +23,7 @@ describe('PersonalOffersService', () => {
};
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
const module = await Test.createTestingModule({
providers: [
PersonalOffersService,
{
......@@ -61,14 +61,13 @@ describe('PersonalOffersService', () => {
it('should return exception if personal offer is not found for given id', async () => {
personalOfferModelMock.findById.mockReturnThis();
personalOfferModelMock.exec.mockResolvedValueOnce(null);
let error;
try {
await personalOffersService.findOne('abcd');
expect(true).toBe(false);
} catch (e) {
error = e;
expect(e.message).toBe('Personal offer does not exist');
expect(e.status).toBe(404);
}
expect(error.message).toBe('Personal offer does not exist');
expect(error.status).toBe(404);
});
});
......@@ -90,14 +89,13 @@ describe('PersonalOffersService', () => {
it('should return exception if personal offer is not found for given id', async () => {
personalOfferModelMock.findById.mockReturnThis();
personalOfferModelMock.exec.mockResolvedValueOnce(null);
let error;
try {
await personalOffersService.update('abcd', updatePersonalOffersDtoDataMock[1]);
expect(true).toBe(false);
} catch (e) {
error = e;
expect(e.message).toBe('Invalid personal offer id for update');
expect(e.status).toBe(400);
}
expect(error.message).toBe('Invalid personal offer id for update');
expect(error.status).toBe(400);
});
});
......@@ -110,14 +108,13 @@ describe('PersonalOffersService', () => {
it('should return exception if personal offer is not found for given id', async () => {
personalOfferModelMock.findById.mockReturnThis();
personalOfferModelMock.exec.mockResolvedValueOnce(null);
let error;
try {
await personalOffersService.delete('abcd');
expect(true).toBe(false);
} catch (e) {
error = e;
expect(e.message).toBe('Invalid personal offer id for deletion');
expect(e.status).toBe(400);
}
expect(error.message).toBe('Invalid personal offer id for deletion');
expect(error.status).toBe(400);
});
});
});
import { HttpModule, HttpService } from '@nestjs/axios';
import { Test, TestingModule } from '@nestjs/testing';
import { Test } from '@nestjs/testing';
import { AxiosResponse } from 'axios';
import { of } from 'rxjs';
import { ConfigurationModule } from '../configuration/configuration.module';
......@@ -21,7 +21,7 @@ describe('PostsController', () => {
};
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
const module = await Test.createTestingModule({
imports: [ConfigurationModule, HttpModule],
providers: [
{
......
import { HttpModule } from '@nestjs/axios';
import { Test, TestingModule } from '@nestjs/testing';
import { Test } from '@nestjs/testing';
import * as _ from 'lodash';
import { ConfigurationModule } from '../configuration/configuration.module';
import { TagEnum } from './enums/tag.enum';
......@@ -207,7 +207,7 @@ describe('PostsService', () => {
const tagsData = [...locationtags, ...publictags, ...otherTags];
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
const module = await Test.createTestingModule({
imports: [ConfigurationModule, HttpModule],
providers: [PostsService],
}).compile();
......
import { getModelToken } from '@nestjs/mongoose';
import { Test, TestingModule } from '@nestjs/testing';
import { Test } from '@nestjs/testing';
import { Model, Query } from 'mongoose';
import { mockFormattedStructures } from '../../../test/mock/services/structures-export.mock.service';
import { StructureFormatted } from '../interfaces/structure-formatted.interface';
......@@ -143,7 +143,7 @@ describe('StructuresExportService', () => {
let structureModel: Model<StructureDocument>;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
const module = await Test.createTestingModule({
providers: [
StructuresExportService,
{
......
import { getModelToken } from '@nestjs/mongoose';
import { Test, TestingModule } from '@nestjs/testing';
import { Test } from '@nestjs/testing';
import { of } from 'rxjs';
import { DataGouvStructure } from '../interfaces/data-gouv-structure.interface';
import { HttpService } from '@nestjs/axios';
......@@ -7,21 +7,20 @@ import { AxiosResponse } from 'axios';
import { mockGouvStructure, mockGouvStructureToResinFormat } from '../../../test/mock/data/gouvStructures.mock.data';
import { StructuresSearchService } from './structures-search.service';
import { StructuresService } from './structures.service';
import { MailerService } from '../../mailer/mailer.service';
import { StructuresImportService } from './structures-import.service';
import { MailerService } from '../../mailer/mailer.service';
describe('StructuresImportService', () => {
let structuresImportService: StructuresImportService;
let structuresSearchService: StructuresSearchService;
let structuresService: StructuresService;
let mailerService: MailerService;
const httpServiceMock = {
get: jest.fn(),
};
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
const module = await Test.createTestingModule({
providers: [
StructuresImportService,
{
......@@ -71,7 +70,6 @@ describe('StructuresImportService', () => {
structuresImportService = module.get<StructuresImportService>(StructuresImportService);
structuresSearchService = module.get<StructuresSearchService>(StructuresSearchService);
structuresService = module.get<StructuresService>(StructuresService);
mailerService = module.get<MailerService>(MailerService);
});
describe('importDataGouvStructures', () => {
......
......@@ -4,7 +4,6 @@ import { HttpService } from '@nestjs/axios';
import { Model, Types } from 'mongoose';
import { Structure, StructureDocument } from '../schemas/structure.schema';
import { InjectModel } from '@nestjs/mongoose';
import { Cron, CronExpression } from '@nestjs/schedule';
import { lastValueFrom } from 'rxjs';
import * as config from './structures-export-configs/services-config.json';
import { Week } from '../../shared/schemas/week.schema';
......
import { Logger } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { Test, TestingModule } from '@nestjs/testing';
import { Test } from '@nestjs/testing';
import { StructuresForSearchServiceMock } from '../../../test/mock/services/structures-for-search.mock.service';
import { MailerModule } from '../../mailer/mailer.module';
import { SearchModule } from '../../search/search.module';
......@@ -11,7 +11,7 @@ describe('StructuresSearchService', () => {
let structureSearchService: StructuresSearchService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
const module = await Test.createTestingModule({
imports: [MailerModule, SearchModule, ConfigModule],
providers: [
StructuresSearchService,
......
......@@ -2,7 +2,7 @@ import { HttpModule, HttpService } from '@nestjs/axios';
import { HttpStatus } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { getModelToken } from '@nestjs/mongoose';
import { Test, TestingModule } from '@nestjs/testing';
import { Test } from '@nestjs/testing';
import * as bcrypt from 'bcrypt';
import { Types } from 'mongoose';
import { of } from 'rxjs';
......@@ -225,7 +225,7 @@ describe('StructuresService', () => {
let structureService: StructuresService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
const module = await Test.createTestingModule({
imports: [HttpModule, MailerModule, SearchModule, ConfigModule],
providers: [
StructuresService,
......@@ -522,7 +522,6 @@ describe('StructuresService', () => {
jest.spyOn(structureService, 'findOne').mockResolvedValue(null);
try {
await structureService.addPersonalOffer('abcd', personalOfferDocumentMock);
// Fail test if above expression doesn't throw anything.
expect(true).toBe(false);
} catch (e) {
expect(e.message).toBe('Structure not found for the personal offer attachment');
......@@ -533,7 +532,6 @@ describe('StructuresService', () => {
jest.spyOn(structureService, 'findOne').mockResolvedValue(structuresDocumentDataMock[1]);
try {
await structureService.addPersonalOffer('6093ba0e2ab5775cfc01ed3e', personalOfferDocumentMock);
// Fail test if above expression doesn't throw anything.
expect(true).toBe(false);
} catch (e) {
expect(e.message).toBe('Personal offer already exist in the structure');
......
......@@ -131,9 +131,6 @@ export class StructuresService {
/**
* Filter offers using structure offers and structure members personalOffers
* @param structures
* @param andFiltersOnOffers
* @returns StructureDocument[]
*/
private async filterOnOffers(
structures: StructureDocument[],
......@@ -171,7 +168,6 @@ export class StructuresService {
/**
* set structure offers and structure social workers personalOffers in non-persistant property structure.categoriesWithPersonalOffers
* @param structure
*/
public async setCategoriesWithPersonalOffers(structure: StructureDocument, onlyOffersWithAppointment: boolean) {
if (onlyOffersWithAppointment) {
......@@ -310,8 +306,6 @@ export class StructuresService {
/**
* Parse equipments. Ex : if structure doesn't have computers but nbComputer changes, then the key is added to equipmentsAndServices
* @param structure
* @returns Structure
*/
public getSelfServiceMaterial(structure: StructureDocument): string[] {
Logger.debug(`getSelfServiceMaterial of ${structure.structureName}`, StructuresService.name);
......@@ -333,7 +327,6 @@ export class StructuresService {
/**
* Parse filter value from string to boolean and map filter category to categories key
* @param filters
*/
private parseFilter(filters: Array<{ [key: string]: unknown }>): Array<{ [key: string]: unknown }> {
return filters.map((filter) => {
......@@ -406,9 +399,6 @@ export class StructuresService {
}
/**
* Map modules labels to ids
* @param structureModule
* @param baseModule
* @returns
*/
public mapModules(structureModule: string[], baseModule: Module[]): string[] {
if (structureModule.length === 0) {
......@@ -610,39 +600,7 @@ export class StructuresService {
}
if (structure.address.postcode) {
let inseeCode: string = null;
const req = `https://apicarto.ign.fr/api/codes-postaux/communes/${structure.address.postcode}`;
this.logger.debug(`Request : ${req}`);
let res;
try {
res = await lastValueFrom(this.httpService.get(encodeURI(req)));
} catch (e) {
this.logger.error(`Request ${encodeURI(req)} failed: ${e}`);
return structure;
}
if (res.data?.length) {
if (res.data.length == 1) {
this.logger.debug(`Insee code ${res.data[0].codeCommune} for ${structure.address.commune}`);
inseeCode = res.data[0].codeCommune;
} else {
// if several commune for this postcode, find which commune we are looking for the insee code
const communes = res.data.filter((commune) => commune.nomCommune == structure.address.commune);
if (communes.length) {
this.logger.debug(`Insee code ${communes[0].codeCommune} for ${structure.address.commune}`);
inseeCode = communes[0].codeCommune;
} else {
this.logger.error(
`Insee code of commune ${structure.address.commune} not found for postcode ${
structure.address.postcode
} in ${JSON.stringify(res.data)} (${req}) --> Postcode reset for future execution`
);
// Reset postcode which is probably wrong because of previous BAL city matching error (cf. issue pamn_client#403 )
structure.address.postcode = '';
}
}
}
const inseeCode = await this.getInseeCode(structure.address.postcode, structure.address.commune);
if (inseeCode) {
structure.address.inseeCode = inseeCode;
const ctm: Module = await this.categoriesService.findCtmByInseeCode(inseeCode);
......@@ -655,9 +613,44 @@ export class StructuresService {
return structure;
}
public async getInseeCode(postcode: string, municipality: string): Promise<string | null> {
const req = `https://apicarto.ign.fr/api/codes-postaux/communes/${postcode}`;
this.logger.debug(`Request : ${req}`);
let res;
try {
res = await lastValueFrom(this.httpService.get(encodeURI(req)));
} catch (e) {
this.logger.error(`Request ${encodeURI(req)} failed: ${e}`);
return null;
}
if (res.data?.length) {
if (res.data.length == 1) {
this.logger.debug(`Insee code ${res.data[0].codeCommune} for ${municipality}`);
return res.data[0].codeCommune;
} else {
// if several municipality for this postcode, find for which municipality we are looking for the insee code
const communes = res.data.filter((commune) => commune.nomCommune == municipality);
if (communes.length) {
this.logger.debug(`Insee code ${communes[0].codeCommune} for ${municipality}`);
return communes[0].codeCommune;
} else {
this.logger.error(
`Insee code of commune ${municipality} not found for postcode ${postcode} in ${JSON.stringify(
res.data
)} (${req})`
);
return null;
}
}
} else {
return null;
}
}
/**
* Get city formatted without "Arrondissement"
* @param {searchQuery} data - Query address
*/
public getFormattedCity(city: string, postcode: string) {
let formattedCity: string = city;
......@@ -674,7 +667,6 @@ export class StructuresService {
/**
* Search structure address based on data search WS
* @param {searchQuery} data - Query address
*/
public async searchAddress(data: { searchQuery: string }): Promise<{ features: PhotonPoints[] }> {
const reqBan = `https://download.data.grandlyon.com/geocoding/photon/api?q=${data.searchQuery}&lang=fr&limit=500&osm_tag=:!construction&osm_tag=:!bus_stop`;
......@@ -704,7 +696,7 @@ export class StructuresService {
/**
* Remove accents from a string by decomposing accented characters and removing diacritical marks.
* @param {string} str - The input string.
* @returns {string} - The string with accents removed.
* @returns {string} The string with accents removed.
*/
const removeAccents = (str: string) => {
if (!str) return '';
......@@ -734,7 +726,6 @@ export class StructuresService {
/**
* Count every value occurrence of a given key
* @param key structure key
* @return [{id: 'key', count: 'value'}]
*/
public async countByStructureKey(key: string, selected: { id: string; text: string }[]) {
const uniqueElements = await this.structureModel.distinct(key).exec();
......@@ -786,8 +777,6 @@ export class StructuresService {
/**
* Set the structure to be deleted in 5 weeks
* @param user IUser
* @param structure StructureDocument
*/
public async setToBeDeleted(user: IUser, structure: StructureDocument): Promise<Structure> {
if (!structure) {
......@@ -802,7 +791,6 @@ export class StructuresService {
/**
* Send an email to structure owners (except the one who asked for the deletion) to inform the structure is will be deleted in 5 weeks
* @param user User
*/
public async sendToBeDeletedNotification(user: IUser, structure: StructureDocument): Promise<void> {
const config = this.mailerService.config;
......@@ -828,8 +816,6 @@ export class StructuresService {
/**
* Cancel the structure deletion when one of the structure owners had asked the structure for deletion
* @param user IUser
* @param structure StructureDocument
*/
public async cancelDelete(user: IUser, structure: StructureDocument): Promise<Structure> {
if (!structure) {
......@@ -846,7 +832,6 @@ export class StructuresService {
/**
* Send an email to other structure owners to inform an owner cancelled the structure deletion
* @param user User
*/
public async sendCancelDeleteNotification(user: IUser, structure: StructureDocument): Promise<void> {
const config = this.mailerService.config;
......@@ -1022,7 +1007,6 @@ export class StructuresService {
/**
* Send an email to prevent outdated
* a new account.
* @param user User
*/
private async sendOutdatedEmailToUser(userEmail: string, structureName: string, id: string): Promise<void> {
const config = this.mailerService.config;
......@@ -1039,7 +1023,6 @@ export class StructuresService {
/**
* Send an email to structure owners and admin in order to accept or decline a join request
* @param user User
*/
public async sendStructureJoinRequest(
user: IUser,
......@@ -1139,8 +1122,6 @@ export class StructuresService {
* Case 1 : null value stands for 'no'
* Case 2: a date stands for 'yes'
* Case 3: no key in document when there is no reply to consent
* @param users {IUser}
* @returns {Structure[]}
*/
public async getAllDataConsentPendingStructures(users: IUser): Promise<Structure[]> {
const data = await Promise.all(
......@@ -1156,9 +1137,6 @@ export class StructuresService {
/**
* Add the personal offer to the structure
* @param structureId string
* @param personalOfferDocument PersonalOfferDocument
* @returns {Structure} structure with personal offer added
*/
public async addPersonalOffer(
structureId: string,
......@@ -1182,7 +1160,6 @@ export class StructuresService {
/**
* Fetch espace coop and filter structures in 69XXX and structures with courriel and phone
* @returns CNFSStructure[]
*/
public getCNFSStructures(): Promise<Array<CNFSStructure>> {
this.logger.debug(`get CNFS structures`);
......@@ -1220,7 +1197,6 @@ export class StructuresService {
/**
* When a structure is created, fetch espace coop and tries to find a match to bind CNFSid to the resin structure.
* @param resinStructureId string
*/
public async bindOneCNFSStructure(resinStructureId: string): Promise<string> {
this.logger.debug(`bind CNFS id to one resin structure`);
......@@ -1357,7 +1333,6 @@ export class StructuresService {
/**
* Updates the denormalized (DN) fields of the structure
* @param user
*/
public async updateDenormalizedFields(idStructure: Types.ObjectId): Promise<StructureDocument> {
const structure = await this.findOne(idStructure.toHexString());
......
import { HttpService } from '@nestjs/axios';
import { HttpStatus } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { Test } from '@nestjs/testing';
import { of } from 'rxjs';
import { PhotonResponseMock } from '../../test/mock/data/dataPhoton.mock.data';
import { structureDtoMock } from '../../test/mock/data/structure.mock.dto';
......@@ -71,7 +71,7 @@ describe('StructuresController', () => {
const mockPersonalOffersService = { delete: jest.fn() };
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
const module = await Test.createTestingModule({
imports: [],
controllers: [StructuresController],
providers: [
......
......@@ -59,7 +59,6 @@ export class StructuresController {
/**
* Return points of given town exist.
* @param zipcode
* @returns Array of points
*/
@Get('coordinates/:zipcode')
......
......@@ -262,9 +262,7 @@ export class TclStopPointService {
}
/**
* Query collection to get neareast coord
* @param pgisCoord PgisCoord
* @param maxDistance number
* Query collection to get nearest coord
*/
public async getStopPointsByDistance(pgisCoord: PgisCoord, maxDistance: number): Promise<TclStopPoint[]> {
return this.tclStopPointModel
......
import { HttpModule } from '@nestjs/axios';
import { HttpStatus } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { Test } from '@nestjs/testing';
import { MailerModule } from '../mailer/mailer.module';
import { TempUserController } from './temp-user.controller';
import { TempUserService } from './temp-user.service';
......@@ -14,7 +14,7 @@ describe('TempUserService', () => {
};
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
const module = await Test.createTestingModule({
imports: [HttpModule, MailerModule],
providers: [{ provide: TempUserService, useValue: mockTempUserService }],
controllers: [TempUserController],
......@@ -47,7 +47,6 @@ describe('TempUserService', () => {
mockTempUserService.findById.mockReturnValueOnce(tmpUser);
try {
await tempUserController.getTempUser('addq651');
// Fail test if above expression doesn't throw anything.
expect(true).toBe(false);
} catch (e) {
expect(e.message).toEqual('Temp user does not exist');
......
import { HttpModule } from '@nestjs/axios';
import { HttpStatus } from '@nestjs/common';
import { getModelToken } from '@nestjs/mongoose';
import { Test, TestingModule } from '@nestjs/testing';
import { Test } from '@nestjs/testing';
import * as ejs from 'ejs';
import { MailerModule } from '../mailer/mailer.module';
import { MailerService } from '../mailer/mailer.service';
......@@ -45,7 +45,7 @@ describe('TempUserService', () => {
// Set up the test module before each test
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
const module = await Test.createTestingModule({
imports: [HttpModule, MailerModule],
providers: [
TempUserService,
......
......@@ -86,7 +86,6 @@ export class TempUserService {
/**
* Send email in order to tell the user that an account is already filled with his structure info.
* @param user User
*/
public async sendUserMail(user: ITempUser, structureName: string, existingUser?: boolean): Promise<void> {
const config = this.mailerService.config;
......