You've already forked homehub
Release 1.3.0
This commit is contained in:
51
packages/homehub_core/tests/api/services.spec.js
Normal file
51
packages/homehub_core/tests/api/services.spec.js
Normal file
@@ -0,0 +1,51 @@
|
||||
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'],
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
32
packages/homehub_core/tests/api/state.spec.js
Normal file
32
packages/homehub_core/tests/api/state.spec.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import * as State from 'src/api/state';
|
||||
import * as RPC from 'src/lib/rpc';
|
||||
|
||||
describe('src/api/state', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(RPC, 'callMethod').and.resolveTo('ok');
|
||||
});
|
||||
|
||||
describe('get', () => {
|
||||
it('calls and RPC method to get frontend state', async () => {
|
||||
// When
|
||||
const result = await State.get();
|
||||
|
||||
// Then
|
||||
expect(result).toEqual('ok');
|
||||
expect(RPC.callMethod).toHaveBeenCalledWith('state.get_frontend');
|
||||
});
|
||||
});
|
||||
|
||||
describe('save', () => {
|
||||
it('calls and RPC method to save frontend state', async () => {
|
||||
// When
|
||||
const result = await State.save('spam');
|
||||
|
||||
// Then
|
||||
expect(result).toEqual('ok');
|
||||
expect(RPC.callMethod).toHaveBeenCalledWith(
|
||||
'state.save_frontend', ['spam']
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user