import * as Services from 'src/api/services'; import * as RPC from 'src/lib/rpc'; describe('src/api/services', () => { beforeEach(() => { spyOn(RPC, 'callMethod').and.resolveTo('ok'); }); describe('start', () => { it('calls and RPC method to start a service', async () => { // When const result = await Services.start('FakeService', 'fake_instance', { 'spam': true, }); // Then expect(result).toEqual('ok'); expect(RPC.callMethod).toHaveBeenCalledWith('services.start', [ 'FakeService', 'fake_instance', {'spam': true}, ]); }); }); describe('stop', () => { it('calls and RPC method to stop a service', async () => { // When const result = await Services.stop('FakeService', 'fake_instance'); // Then expect(result).toEqual('ok'); expect(RPC.callMethod).toHaveBeenCalledWith('services.stop', [ 'FakeService', 'fake_instance', ]); }); }); describe('use', () => { it('calls and RPC method to use a service capability', async () => { // When const result = await Services.use( 'FakeService', 'fake_instance', 'testing', ['spam'], ); // Then expect(result).toEqual('ok'); expect(RPC.callMethod).toHaveBeenCalledWith('services.use', [ 'FakeService', 'fake_instance', 'testing', ['spam'], ]); }); }); });