mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-31 08:25:35 +00:00
Improve ServerError tests
This commit is contained in:
parent
0c58ec9260
commit
9888b6db74
@ -12,6 +12,11 @@ class MyType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('ServerError', () => {
|
describe('ServerError', () => {
|
||||||
|
it('should construct with message', () => {
|
||||||
|
const error = new Error("test");
|
||||||
|
expect(error.message).toEqual("test");
|
||||||
|
});
|
||||||
|
|
||||||
it('should construct ServerError from error', () => {
|
it('should construct ServerError from error', () => {
|
||||||
const error = new Error("test");
|
const error = new Error("test");
|
||||||
const serverError = ServerError.fromError("new message", error);
|
const serverError = ServerError.fromError("new message", error);
|
||||||
@ -22,13 +27,22 @@ describe('ServerError', () => {
|
|||||||
|
|
||||||
|
|
||||||
describe('ServerErrorHandler', () => {
|
describe('ServerErrorHandler', () => {
|
||||||
it('should handle HttpErrorResponse', () => {
|
it('should handle HttpErrorResponse with status 0', () => {
|
||||||
const error = new HttpErrorResponse({ status: 0 });
|
const error = new HttpErrorResponse({ status: 0 });
|
||||||
|
|
||||||
const handler = new ServerErrorHandler();
|
const handler = new ServerErrorHandler();
|
||||||
const result = handler.handleError(error);
|
const result = handler.handleError(error);
|
||||||
|
|
||||||
expect(result.error.toString()).toEqual('Error: Server is unreachable');
|
expect(result.error.message).toEqual('Server is unreachable');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not handle HttpErrorResponse with status!=0', () => {
|
||||||
|
const error = new HttpErrorResponse({ status: 499 });
|
||||||
|
|
||||||
|
const handler = new ServerErrorHandler();
|
||||||
|
const result = handler.handleError(error);
|
||||||
|
|
||||||
|
expect(result.error.message).toEqual('Http failure response for (unknown url): 499 undefined');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user