mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-01-19 03:06:31 +00:00
Improve ServerError tests
This commit is contained in:
parent
0c58ec9260
commit
9888b6db74
@ -12,6 +12,11 @@ class MyType {
|
||||
}
|
||||
|
||||
describe('ServerError', () => {
|
||||
it('should construct with message', () => {
|
||||
const error = new Error("test");
|
||||
expect(error.message).toEqual("test");
|
||||
});
|
||||
|
||||
it('should construct ServerError from error', () => {
|
||||
const error = new Error("test");
|
||||
const serverError = ServerError.fromError("new message", error);
|
||||
@ -22,13 +27,22 @@ describe('ServerError', () => {
|
||||
|
||||
|
||||
describe('ServerErrorHandler', () => {
|
||||
it('should handle HttpErrorResponse', () => {
|
||||
it('should handle HttpErrorResponse with status 0', () => {
|
||||
const error = new HttpErrorResponse({ status: 0 });
|
||||
|
||||
const handler = new ServerErrorHandler();
|
||||
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…
Reference in New Issue
Block a user