mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
test: Use individual error assertions.
This commit is contained in:
parent
fdc52f50e5
commit
8a62938c18
@ -16,7 +16,7 @@ class FixedHttpError extends HttpError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('An HttpError', (): void => {
|
describe('HttpError', (): void => {
|
||||||
const errors: [string, number, typeof FixedHttpError][] = [
|
const errors: [string, number, typeof FixedHttpError][] = [
|
||||||
[ 'BadRequestHttpError', 400, BadRequestHttpError ],
|
[ 'BadRequestHttpError', 400, BadRequestHttpError ],
|
||||||
[ 'UnauthorizedHttpError', 401, UnauthorizedHttpError ],
|
[ 'UnauthorizedHttpError', 401, UnauthorizedHttpError ],
|
||||||
@ -30,11 +30,23 @@ describe('An HttpError', (): void => {
|
|||||||
[ 'NotImplementedHttpError', 501, NotImplementedHttpError ],
|
[ 'NotImplementedHttpError', 501, NotImplementedHttpError ],
|
||||||
];
|
];
|
||||||
|
|
||||||
it.each(errors)('%s is valid', (name, statusCode, constructor): void => {
|
describe.each(errors)('%s', (name, statusCode, constructor): void => {
|
||||||
const instance = new constructor('message');
|
const instance = new constructor('my message');
|
||||||
expect(constructor.isInstance(instance)).toBeTruthy();
|
|
||||||
expect(instance.statusCode).toBe(statusCode);
|
it(`is an instance of ${name}.`, (): void => {
|
||||||
expect(instance.name).toBe(name);
|
expect(constructor.isInstance(instance)).toBeTruthy();
|
||||||
expect(instance.message).toBe('message');
|
});
|
||||||
|
|
||||||
|
it(`has name ${name}.`, (): void => {
|
||||||
|
expect(instance.name).toBe(name);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`has status code ${statusCode}.`, (): void => {
|
||||||
|
expect(instance.statusCode).toBe(statusCode);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('sets the message.', (): void => {
|
||||||
|
expect(instance.message).toBe('my message');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user