0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00
verdaccio/packages/middleware/test/encode.spec.ts

22 lines
559 B
TypeScript
Raw Normal View History

import request from 'supertest';
import { HTTP_STATUS } from '@verdaccio/core';
import { encodeScopePackage } from '../src';
import { getApp } from './helper';
test('encode is json', async () => {
const app = getApp([]);
// @ts-ignore
app.use(encodeScopePackage);
// @ts-ignore
app.get('/:id', (req, res) => {
const { id } = req.params;
res.status(HTTP_STATUS.OK).json({ id });
});
const res = await request(app).get('/@scope/foo');
expect(res.body).toEqual({ id: '@scope/foo' });
expect(res.status).toEqual(HTTP_STATUS.OK);
});