Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Merge 03996ba into 808bfbb
Browse files Browse the repository at this point in the history
  • Loading branch information
jperata committed Oct 18, 2018
2 parents 808bfbb + 03996ba commit c3000e0
Showing 1 changed file with 33 additions and 0 deletions.
Expand Up @@ -47,6 +47,29 @@ describe("VirtualDeviceClient", function() {
}
});

it("Throws error if error is sent", async function () {
const globalClone = Object.assign({}, globalModule);
globalClone.Global.config = function () {
return {
virtualDeviceToken: () => "Token",
updateVirtualDeviceToken: () => {
},
};
};

mockery.registerMock("../core/global", globalClone);
mockery.registerMock("virtual-device-sdk", {
VirtualDevice: ExceptionThrowingVirtualDevice,
});

const VirtualDeviceClient = require("../../lib/external/virtual-device").VirtualDeviceClient;
try {
await VirtualDeviceClient.speak("Hello world");
} catch (error) {
assert.equal(error.message, "Something broke");
}
});

it("Works when token exists on config", async function () {

const globalClone = Object.assign({}, globalModule);
Expand Down Expand Up @@ -177,3 +200,13 @@ class VirtualDevice {
messageParam = utterance;
}
}

class ExceptionThrowingVirtualDevice {
public constructor(token: string) {
constructorToken = token;
}

public message = (utterance: string) => {
throw new Error("Something broke");
}
}

0 comments on commit c3000e0

Please sign in to comment.