Skip to content

Commit

Permalink
socketmock
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasHub committed Dec 31, 2024
1 parent e930a93 commit 6e1d9fd
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 2 deletions.
20 changes: 20 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"lint-staged": "^10.0.1",
"mongodb-memory-server": "^8.12.1",
"nodemon": "^1.11.0",
"socket.io-mock": "^1.3.2",
"supertest": "^6.3.3",
"ts-jest": "^29.0.5",
"typescript": "4.3"
Expand Down
4 changes: 3 additions & 1 deletion backend/src/controllers/tests/1-clients.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { IAudit } from '../../models/common';
import { ObjectID } from 'mongodb'
import { IClient } from '../../models/clients'
import { Jwt } from '../../models/technical'
import { saveClient } from '../clients'
import { saveClient } from '../clients';
import MockedSocket from 'socket.io-mock';

const fakeUser: Jwt = {
data: {
Expand Down Expand Up @@ -44,6 +45,7 @@ describe('clients controller :: saveClient creation', () => {
user: fakeUser,
body: {...fakeClient, name: 'Company X'},
db: fakeDb,
io: new MockedSocket(),
} as ConfacRequest;

const res = {
Expand Down
2 changes: 2 additions & 0 deletions backend/src/controllers/tests/2-consultants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { saveConsultant } from '../consultants';
import { IConsultant } from '../../models/consultants';
import { MongoMemoryServer } from 'mongodb-memory-server';


const fakeUser: Jwt = {
data: { _id: '_id', email: 'string', firstName: 'first', name: 'name', alias: 'alias', active: true },
iat: 0, exp: 0,
Expand All @@ -29,6 +30,7 @@ const createFakeRequestAndResponse = (db: Db, consultant: Partial<IConsultant> |
user: fakeUser,
body: {...fakeConsultant, ...(consultant || {})},
db,
io: new MockedSocket(),
} as ConfacRequest;

const res = {
Expand Down
1 change: 1 addition & 0 deletions backend/src/models/technical.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Request} from 'express';
import { Server } from 'socket.io';

export type Jwt = {
data: {
Expand Down
2 changes: 1 addition & 1 deletion backend/types/express/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ declare global {
namespace Express {
export interface Request {
db: Db;
io: Server
io: Server;
}
}
}

0 comments on commit 6e1d9fd

Please sign in to comment.