mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-04-08 02:54:16 +00:00
getLocalServer tests
This commit is contained in:
parent
bcc21da585
commit
290ce6641f
@ -130,4 +130,39 @@ describe('ServerService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should create local server when missing', (done) => {
|
||||
spyOn(db, 'getAll').and.returnValue(Promise.resolve([]));
|
||||
spyOn(service, 'create').and.returnValue(Promise.resolve(new Server()));
|
||||
|
||||
const expectedServer = new Server();
|
||||
expectedServer.name = 'local';
|
||||
expectedServer.ip = 'hostname';
|
||||
expectedServer.port = 9999;
|
||||
expectedServer.is_local = true;
|
||||
|
||||
service.getLocalServer('hostname', 9999).then(() => {
|
||||
expect(service.create).toHaveBeenCalledWith(expectedServer)
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should update local server when found', (done) => {
|
||||
const server = new Server();
|
||||
server.name = 'local';
|
||||
server.ip = 'hostname';
|
||||
server.port = 9999;
|
||||
server.is_local = true;
|
||||
|
||||
spyOn(db, 'getAll').and.returnValue(Promise.resolve([server]));
|
||||
spyOn(service, 'update').and.returnValue(Promise.resolve(new Server()));
|
||||
|
||||
service.getLocalServer('hostname-2', 11111).then(() => {
|
||||
server.ip = 'hostname-2';
|
||||
server.port = 11111;
|
||||
|
||||
expect(service.update).toHaveBeenCalledWith(server);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user