Skip to content

Commit 493c33c

Browse files
SharpDevOps10KobbAsa
authored andcommitted
testing: added tests for findAllQueuesByLabId
1 parent 619327f commit 493c33c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/queues/queues.service.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { UsersModule } from '../users/users.module';
1111
import { CreateQueueDto } from './dto/create-queue.dto';
1212
import { ConflictException, ForbiddenException, NotFoundException } from '@nestjs/common';
1313
import { Request } from 'express';
14+
import { Queue } from '@prisma/client';
1415

1516
describe('QueuesService', () => {
1617
let prismaService: PrismaService;
@@ -87,6 +88,29 @@ describe('QueuesService', () => {
8788
});
8889
});
8990

91+
describe('findAllQueuesByLabId', () => {
92+
it('should return an array of queues', async () => {
93+
const labId = 'test-lab-id';
94+
const user = await prismaService.user.create({
95+
data: {
96+
97+
password: '123456',
98+
firstName: 'John',
99+
lastName: 'Doe',
100+
admin: false,
101+
approved: true,
102+
},
103+
});
104+
105+
const queueDto: CreateQueueDto = { labId };
106+
const queue1 = await queuesService.createQueue(queueDto, user.id);
107+
const queue2 = await queuesService.createQueue(queueDto, user.id);
108+
109+
const result = await queuesService.findAllQueuesByLabId(labId);
110+
expect(result).toEqual([queue1, queue2]);
111+
});
112+
});
113+
90114
describe('deleteQueueById', () => {
91115
it('should allow admin to delete a queue', async () => {
92116
const admin = await prismaService.user.create({

0 commit comments

Comments
 (0)