homehub/packages/homehub_core/tests/api/state.spec.js

33 lines
800 B
JavaScript
Raw Normal View History

2021-08-26 10:33:15 +00:00
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']
);
});
});
});