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
Commits on Source (4)
Showing
with 898 additions and 2582 deletions
This diff is collapsed.
......@@ -218,6 +218,7 @@ export class AdminController {
return formatUsers.map((user) => {
return {
id: user._id,
createdAt: user.createdAt ? user.createdAt.toLocaleDateString() : '',
surname: user.surname,
name: user.name,
email: user.email,
......
......@@ -6,6 +6,6 @@ import { ContactService } from './contact.service';
@Module({
imports: [MailerModule],
controllers: [ContactController],
providers: [ContactService]
providers: [ContactService],
})
export class ContactModule {}
import { Db } from 'mongodb';
import { getDb } from '../migrations-utils/db';
export const up = async () => {
const db: Db = await getDb();
};
export const down = async () => {
const db: Db = await getDb();
/*
Code you downgrade script here!
*/
};
......@@ -309,15 +309,15 @@ describe('PostsService', () => {
};
it('should format post with no custom expert', () => {
const objCp = { ...postToFormat };
let result = { ...postToFormat };
const result = { ...postToFormat };
result.excerpt = 'Inconnu';
result.feature_image = 'https://localhost/blog/content/images/2021/12/dacc-4.png';
expect(service.formatPosts(objCp)).toEqual(result);
});
it('should format post with custom expert', () => {
let objCp = { ...postToFormat };
const objCp = { ...postToFormat };
objCp.custom_excerpt = 'Toto';
let result = { ...postToFormat };
const result = { ...postToFormat };
result.custom_excerpt = 'Toto';
result.feature_image = 'https://localhost/blog/content/images/2021/12/dacc-4.png';
expect(service.formatPosts(objCp)).toEqual(result);
......
......@@ -420,6 +420,7 @@ describe('StructuresService', () => {
name: 'Jacques',
surname: 'Dupont',
phone: '06 06 06 06 06',
createdAt: new Date('2022-05-25T09:48:28.824Z'),
} as IUser;
jest
.spyOn(service, 'findOne')
......@@ -470,6 +471,7 @@ describe('StructuresService', () => {
name: 'Jacques',
surname: 'Dupont',
phone: '06 06 06 06 06',
createdAt: new Date('2022-05-25T09:48:28.824Z'),
} as IUser;
jest
.spyOn(service, 'findOne')
......
......@@ -63,7 +63,8 @@ export class StructuresService {
filters = filters?.filter((elem) => Object.keys(elem)[0].length != 0);
if (multipleFilters) {
const filtersArrays = await Promise.all(this.fillFilters(multipleFilters));
multipleFilters = [].concat.apply([], filtersArrays);
multipleFilters = [...filtersArrays];
// multipleFilters = [].concat.apply([], filtersArrays);
}
if (!ids.length) {
return [];
......@@ -345,7 +346,7 @@ export class StructuresService {
});
}
public mapFormationModules(structureModule: string[], baseModule: CategoriesFormationsModule[]): string[] {
if (structureModule == []) {
if (structureModule.length === 0) {
return [];
}
return structureModule.map((id) => {
......@@ -354,7 +355,7 @@ export class StructuresService {
});
}
public mapModules(structureModule: string[], baseModule: CategoriesModule[]): string[] {
if (structureModule == []) {
if (structureModule.length === 0) {
return [];
}
return structureModule.map((id) => {
......@@ -469,8 +470,8 @@ export class StructuresService {
const reqBal = `https://download.data.grandlyon.com/geocoding/photon-bal/api?q=${data.searchQuery}&lang=fr&limit=500&osm_tag=:!construction&osm_tag=:!bus_stop`;
const requestGroup = (url): Promise<{ features: { geometry: {}; type: string; properties: {} }[] }> =>
new Promise((resolve, reject) => {
const requestGroup = (url): Promise<{ features: { geometry: any; type: string; properties: any }[] }> =>
new Promise((resolve) => {
this.logger.debug(`Search request: ${encodeURI(url)}`, 'StructureService');
return this.httpService
.request({
......@@ -771,6 +772,7 @@ export class StructuresService {
users.map(async (user) => {
return {
id: user._id,
createdAt: user.createdAt ? user.createdAt.toLocaleDateString() : '',
surname: user.surname,
name: user.name,
email: user.email,
......
......@@ -138,6 +138,7 @@ describe('AuthController', () => {
name: user.name,
surname: user.surname,
emailVerified: true,
createdAt: new Date('2022-05-25T09:48:28.824Z'),
password: user.password,
validationToken: null,
role: null,
......@@ -210,6 +211,7 @@ describe('AuthController', () => {
name: user.name,
surname: user.surname,
emailVerified: true,
createdAt: new Date('2022-05-25T09:48:28.824Z'),
password: user.password,
validationToken: null,
role: null,
......
......@@ -69,7 +69,7 @@ describe('TempUserService', () => {
it('should delete a temp user', async () => {
const tmpUser = { email: 'test2@test.com', pendingStructuresLink: [] };
tempUserModelMock.findOne.mockResolvedValueOnce(tmpUser);
tempUserModelMock.deleteOne.mockImplementationOnce(() => {});
tempUserModelMock.deleteOne.mockImplementationOnce(() => ({}));
expect(await service.delete('toto@test.com')).toEqual(tmpUser);
});
it('should return an error : user does not exist', async () => {
......
import { IsEmail, IsNotEmpty, IsString } from 'class-validator';
import { IsNotEmpty, IsString } from 'class-validator';
export class ProfileDto {
@IsNotEmpty()
......
......@@ -69,7 +69,7 @@ describe('isPersonalOfferOwner', () => {
});
it('should return false if structure is not user linked structures', async () => {
jest.spyOn(reflector, 'get').mockImplementation((a: any, b: any) => []);
jest.spyOn(reflector, 'get').mockImplementation(() => []);
const context = createMock<ExecutionContext>({
getHandler: jest.fn(),
switchToHttp: jest.fn().mockReturnValue({
......
......@@ -69,7 +69,7 @@ describe('isStrructureOwner', () => {
});
it('should return false if structure is not user linked structures', async () => {
jest.spyOn(reflector, 'get').mockImplementation((a: any, b: any) => []);
jest.spyOn(reflector, 'get').mockImplementation(() => []);
const context = createMock<ExecutionContext>({
getHandler: jest.fn(),
switchToHttp: jest.fn().mockReturnValue({
......
......@@ -37,7 +37,7 @@ describe('RolesGuard', () => {
});
it('should skip(return true) if the `HasRoles` decorator is not set', async () => {
jest.spyOn(reflector, 'get').mockImplementation((a: any, b: any) => null);
jest.spyOn(reflector, 'get').mockImplementation(() => null);
const context = createMock<ExecutionContext>();
const result = await guard.canActivate(context);
......@@ -46,7 +46,7 @@ describe('RolesGuard', () => {
});
it('should return true if the `HasRoles` decorator and role is admin', async () => {
jest.spyOn(reflector, 'get').mockImplementation((a: any, b: any) => ['admin']);
jest.spyOn(reflector, 'get').mockImplementation(() => ['admin']);
const context = createMock<ExecutionContext>({
getHandler: jest.fn(),
switchToHttp: jest.fn().mockReturnValue({
......@@ -62,7 +62,7 @@ describe('RolesGuard', () => {
});
it('should return false if the `HasRoles` decorator is set but role is not allowed', async () => {
jest.spyOn(reflector, 'get').mockImplementation((a: any, b: any) => ['admin']);
jest.spyOn(reflector, 'get').mockImplementation(() => ['admin']);
const context = createMock<ExecutionContext>({
getHandler: jest.fn(),
switchToHttp: jest.fn().mockReturnValue({
......@@ -78,7 +78,7 @@ describe('RolesGuard', () => {
});
it('should return true if the `HasRoles` decorator is and role is not allowed', async () => {
jest.spyOn(reflector, 'get').mockImplementation((a: any, b: any) => ['user']);
jest.spyOn(reflector, 'get').mockImplementation(() => ['user']);
const context = createMock<ExecutionContext>({
getHandler: jest.fn(),
switchToHttp: jest.fn().mockReturnValue({
......
......@@ -5,8 +5,11 @@ import { Employer } from './employer.schema';
import { Job } from './job.schema';
import { UserRole } from '../enum/user-role.enum';
@Schema()
@Schema({ timestamps: true })
export class User {
@Prop()
createdAt: Date;
@Prop({ required: true })
email: string;
......
......@@ -75,6 +75,7 @@ describe('UsersService', () => {
name: 'Jacques',
surname: 'Dupont',
phone: '06 06 06 06 06',
createdAt: new Date('2022-05-25T09:48:28.824Z'),
employer: {
name: 'test',
validated: true,
......@@ -145,6 +146,7 @@ describe('UsersService', () => {
name: 'Jacques',
surname: 'Dupont',
phone: '06 06 06 06 06',
createdAt: new Date('2022-05-25T09:48:28.824Z'),
employer: {
name: 'test',
validated: true,
......@@ -218,6 +220,7 @@ describe('UsersService', () => {
name: 'Jacques',
surname: 'Dupont',
phone: '06 06 06 06 06',
createdAt: new Date('2022-05-25T09:48:28.824Z'),
changeEmailToken:
'9bb3542bdc5ca8801ad4cee00403c1052bc95dee768dcbb65b1f719870578ed79f71f52fdc3e6bf02fd200a72b8b6f56fc26950df30c8cd7e427a485f80181b9',
employer: {
......@@ -263,6 +266,7 @@ describe('UsersService', () => {
name: 'Jacques',
surname: 'Dupont',
phone: '06 06 06 06 06',
createdAt: new Date('2022-05-25T09:48:28.824Z'),
employer: {
name: 'test',
validated: true,
......@@ -370,6 +374,7 @@ describe('UsersService', () => {
name: 'Jacques',
surname: 'Dupont',
phone: '06 06 06 06 06',
createdAt: new Date('2022-05-25T09:48:28.824Z'),
} as IUser,
];
jest.spyOn(service, 'findAllUnattached').mockImplementation(async (): Promise<IUser[]> => result);
......@@ -438,19 +443,37 @@ describe('UsersService', () => {
expect(spyer).toBeCalledTimes(1);
});
it('should return true if a user is linked to a given employer', async () => {});
it('should fetch users attached to a given employer', async () => {});
it('should populate an employer with a list of attached users', async () => {});
it("should update user's employer ", async () => {});
it('should return true if a user is linked to a given employer', async () => {
return;
});
it('should fetch users attached to a given employer', async () => {
return;
});
it('should populate an employer with a list of attached users', async () => {
return;
});
it("should update user's employer ", async () => {
return;
});
});
describe('user job', () => {
it('should replace job with a new one', async () => {});
it('should replace job with a new one', async () => {
return;
});
it('should return true if a user is linked to a given job', async () => {});
it('should fetch users attached to a given job', async () => {});
it('should populate an job with a list of attached users', async () => {});
it("should update user's job ", async () => {});
it('should return true if a user is linked to a given job', async () => {
return;
});
it('should fetch users attached to a given job', async () => {
return;
});
it('should populate an job with a list of attached users', async () => {
return;
});
it("should update user's job ", async () => {
return;
});
});
describe('updateDetails', () => {
......
......@@ -16,9 +16,6 @@ describe('AppController (e2e)', () => {
});
it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!');
return request(app.getHttpServer()).get('/').expect(200).expect('Hello World!');
});
});