Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe('test errors log', () => {
const middlewareObject = { name: 'verdaccio',
request: {
method: 'POST',
url: '/-/npm/v1/user'
},
user: 'userTest2001',
remoteIP: '::ffff:127.0.0.1',
status: HTTP_STATUS.UNAUTHORIZED,
error: 'some error',
msg: '@{status}, user: @{user}(@{remoteIP}), req: \'@{request.method} @{request.url}\', error: @{!error}'
};
test('should display error log', () => {
const expectedErrorMessage = `401, user: userTest2001(::ffff:127.0.0.1), req: 'POST /-/npm/v1/user', error: some error`;
expect(fillInMsgTemplate(LOG_VERDACCIO_ERROR, middlewareObject, false))
.toEqual(expectedErrorMessage);
});
test('should display error log with colors', () => {
const expectedErrorMessage = `401, user: g[userTest2001](g[::ffff:127.0.0.1]), req: 'g[POST] g[/-/npm/v1/user]', error: r[some error]`;
expect(fillInMsgTemplate(LOG_VERDACCIO_ERROR, middlewareObject, true))
.toEqual(expectedErrorMessage);
});
});