mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-13 20:48:12 +00:00
Tests for ServerError
This commit is contained in:
@ -1,9 +1,9 @@
|
|||||||
import { TestBed, } from '@angular/core/testing';
|
import { TestBed, } from '@angular/core/testing';
|
||||||
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/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 { Server } from '../models/server';
|
||||||
import { HttpServer } from './http-server.service';
|
import {HttpServer, ServerError, ServerErrorHandler} from './http-server.service';
|
||||||
import { getTestServer } from './testing';
|
import { getTestServer } from './testing';
|
||||||
import { AppTestingModule } from "../testing/app-testing/app-testing.module";
|
import { AppTestingModule } from "../testing/app-testing/app-testing.module";
|
||||||
|
|
||||||
@ -11,6 +11,27 @@ class MyType {
|
|||||||
id: number;
|
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', () => {
|
describe('HttpServer', () => {
|
||||||
let httpClient: HttpClient;
|
let httpClient: HttpClient;
|
||||||
|
Reference in New Issue
Block a user