mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-09 06:22:40 +00:00
26 lines
944 B
TypeScript
26 lines
944 B
TypeScript
|
import { expect } from 'chai';
|
||
|
|
||
|
import * as actions from '~/src/device-api/actions';
|
||
|
|
||
|
describe('device-api/actions', () => {
|
||
|
describe('runs healthchecks', () => {
|
||
|
const taskTrue = () => Promise.resolve(true);
|
||
|
const taskFalse = () => Promise.resolve(false);
|
||
|
const taskError = () => {
|
||
|
throw new Error();
|
||
|
};
|
||
|
|
||
|
it('resolves true if all healthchecks pass', async () => {
|
||
|
expect(await actions.runHealthchecks([taskTrue, taskTrue])).to.be.true;
|
||
|
});
|
||
|
|
||
|
it('resolves false if any healthchecks throw an error or fail', async () => {
|
||
|
expect(await actions.runHealthchecks([taskTrue, taskFalse])).to.be.false;
|
||
|
expect(await actions.runHealthchecks([taskTrue, taskError])).to.be.false;
|
||
|
expect(await actions.runHealthchecks([taskFalse, taskError])).to.be.false;
|
||
|
expect(await actions.runHealthchecks([taskFalse, taskFalse])).to.be.false;
|
||
|
expect(await actions.runHealthchecks([taskError, taskError])).to.be.false;
|
||
|
});
|
||
|
});
|
||
|
});
|