homehub/packages/homehub_core/tests/api/state.spec.js
2021-08-26 12:33:15 +02:00

33 lines
800 B
JavaScript

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']
);
});
});
});