mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-04-07 18:44:13 +00:00
Tests for ServerError
This commit is contained in:
parent
c2f37a5f5f
commit
acc4fdc3c5
@ -1,9 +1,9 @@
|
||||
import { TestBed, } from '@angular/core/testing';
|
||||
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
|
||||
|
||||
import { Server } from '../models/server';
|
||||
import { HttpServer } from './http-server.service';
|
||||
import {HttpServer, ServerError, ServerErrorHandler} from './http-server.service';
|
||||
import { getTestServer } from './testing';
|
||||
import { AppTestingModule } from "../testing/app-testing/app-testing.module";
|
||||
|
||||
@ -11,6 +11,27 @@ class MyType {
|
||||
id: number;
|
||||
}
|
||||
|
||||
describe('ServerError', () => {
|
||||
it('should construct ServerError from error', () => {
|
||||
const error = new Error("test");
|
||||
const serverError = ServerError.fromError("new message", error);
|
||||
expect(serverError.originalError).toEqual(error);
|
||||
expect(serverError.message).toEqual("new message");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('ServerErrorHandler', () => {
|
||||
it('should handle HttpErrorResponse', () => {
|
||||
const error = new HttpErrorResponse({ status: 0 });
|
||||
|
||||
const handler = new ServerErrorHandler();
|
||||
const result = handler.handleError(error);
|
||||
|
||||
expect(result.error.toString()).toEqual('Error: Server is unreachable');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('HttpServer', () => {
|
||||
let httpClient: HttpClient;
|
||||
|
Loading…
x
Reference in New Issue
Block a user