Skip to content

Commit

Permalink
Enhance ticket tests: Update error message to use dynamic tickets path
Browse files Browse the repository at this point in the history
  • Loading branch information
S0naliThakur committed Jan 8, 2025
1 parent a4b9150 commit c7b583b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/unit/src/routes/tickets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jest.mock('../../../../src/Config', () => ({
import { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify'
import { readFileSync } from 'fs'
import { ticketsRouter, ticketCache } from '../../../../src/routes/tickets'
import * as path from 'path';

// Updated mock data to match schema
const mockValidTickets = [{
Expand All @@ -38,6 +39,8 @@ const mockValidTickets = [{
type: "silver"
}];

const TICKETS_PATH = path.resolve(process.cwd(), 'static', 'tickets.json');

function createMockReply() {
const mockSend = jest.fn();
const mockCode = jest.fn().mockImplementation((code) => ({
Expand Down Expand Up @@ -103,7 +106,7 @@ describe('Ticket Routes', () => {
expect(code).toHaveBeenCalledWith(500);
expect(send).toHaveBeenCalledWith({
code: 'TICKETS_FILE_NOT_ACCESSIBLE',
error: 'Unable to access tickets configuration: /home/sothakur/work/SHARD-1377/archive-server/static/tickets.json'
error: `Unable to access tickets configuration: ${TICKETS_PATH}`
});
});

Expand Down

0 comments on commit c7b583b

Please sign in to comment.