"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = __importDefault(require("express"));
const supertest_1 = __importDefault(require("supertest"));
const id_number_middleware_1 = __importDefault(require("./id-number-middleware"));
describe('idNumberMiddleware', () => {
    it('should pass when id is a valid integer', async () => {
        const app = (0, express_1.default)();
        app.use('/:id', (0, id_number_middleware_1.default)());
        app.get('/:id', (req, res) => {
            res.status(200).send('Valid ID');
        });
        await (0, supertest_1.default)(app)
            .get('/123')
            .expect(200)
            .expect((res) => {
            expect(res.text).toBe('Valid ID');
        });
    });
    it('should throw BadDataError when id is not a valid integer', async () => {
        const app = (0, express_1.default)();
        app.use('/:id', (0, id_number_middleware_1.default)());
        app.get('/:id', (req, res) => {
            res.status(200).send('This should not be executed');
        });
        const { body } = await (0, supertest_1.default)(app).get('/abc').expect(400);
        expect(body).toMatchObject({
            details: [{ message: 'ID should be an integer' }],
        });
    });
});
//# sourceMappingURL=id-number-middleware.test.js.map