Skip to content

Commit

Permalink
vision tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SillyFreak committed Sep 30, 2019
1 parent 097c22c commit 21e2aec
Showing 1 changed file with 98 additions and 0 deletions.
98 changes: 98 additions & 0 deletions test/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,104 @@ describe('Client', () => {
await hedgehog.setSpeaker(440);
});

it('`openCamera` should work', async () => {
mock_server(
[[new vision.OpenCameraAction()], [new ack.Acknowledgement()]],
);

await hedgehog.openCamera();
});

it('`closeCamera` should work', async () => {
mock_server(
[[new vision.CloseCameraAction()], [new ack.Acknowledgement()]],
);

await hedgehog.closeCamera();
});

it('`createChannel` should work', async () => {
mock_server(
[[new vision.CreateChannelAction({
foo: { kind: vision.ChannelKind.FACES },
})], [new ack.Acknowledgement()]],
);

await hedgehog.createChannel('foo', { kind: vision.ChannelKind.FACES });
});

it('`updateChannel` should work', async () => {
mock_server(
[[new vision.UpdateChannelAction({
foo: { kind: vision.ChannelKind.FACES },
})], [new ack.Acknowledgement()]],
);

await hedgehog.updateChannel('foo', { kind: vision.ChannelKind.FACES });
});

it('`deleteChannel` should work', async () => {
mock_server(
[[new vision.DeleteChannelAction(['foo'])], [new ack.Acknowledgement()]],
);

await hedgehog.deleteChannel('foo');
});

it('`getChannel` should work', async () => {
mock_server(
[[new vision.ChannelRequest(['foo'])], [new vision.ChannelReply({
foo: { kind: vision.ChannelKind.FACES },
})]],
);

assert.deepStrictEqual(await hedgehog.getChannel('foo'), { kind: vision.ChannelKind.FACES });
});

it('`getChannels` should work', async () => {
mock_server(
[[new vision.ChannelRequest([])], [new vision.ChannelReply({
foo: { kind: vision.ChannelKind.FACES },
})]],
);

assert.deepStrictEqual(await hedgehog.getChannels(), {
foo: {kind: vision.ChannelKind.FACES},
});
});

it('`captureFrame` should work', async () => {
mock_server(
[[new vision.CaptureFrameAction()], [new ack.Acknowledgement()]],
);

await hedgehog.captureFrame();
});

it('`getFrame` should work', async () => {
mock_server(
[[new vision.FrameRequest('foo')], [new vision.FrameReply('foo', Uint8Array.of())]],
[[new vision.FrameRequest(null)], [new vision.FrameReply('foo', Uint8Array.of())]],
);

assert.deepStrictEqual(await hedgehog.getFrame('foo'), Uint8Array.of());
assert.deepStrictEqual(await hedgehog.getFrame(), Uint8Array.of());
});

it('`getFeature` should work', async () => {
mock_server(
[[new vision.FeatureRequest('foo')], [new vision.FeatureReply('foo', {
kind: vision.ChannelKind.FACES,
faces: [],
})]],
);

assert.deepStrictEqual(await hedgehog.getFeature('foo'), {
kind: vision.ChannelKind.FACES,
faces: [],
});
});

after(() => {
hedgehog.close();
hedgehog = null;
Expand Down

0 comments on commit 21e2aec

Please sign in to comment.