2018-01-02 08:39:40 -07:00
|
|
|
jest.mock("../device", () => {
|
|
|
|
return { getDevice: () => ({ publish: jest.fn() }) };
|
|
|
|
});
|
|
|
|
|
2017-12-29 16:41:45 -07:00
|
|
|
import { isSafeError, inferUpdateId } from "../interceptor_support";
|
2017-11-15 11:37:28 -07:00
|
|
|
|
|
|
|
describe("isSafeError", () => {
|
|
|
|
it("infers if it is safe to proceed", () => {
|
|
|
|
const notSafe = { response: { status: "four oh four" } };
|
|
|
|
expect(isSafeError(notSafe)).toBe(false);
|
|
|
|
const safe = { response: { status: 404 } };
|
|
|
|
expect(isSafeError(safe)).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
2017-12-29 16:41:45 -07:00
|
|
|
|
|
|
|
describe("inferUpdateId", () => {
|
|
|
|
it("it handles failure by returning `*`", () => {
|
|
|
|
expect(inferUpdateId("foo/123/456")).toBe("*");
|
2018-08-08 08:44:12 -06:00
|
|
|
// tslint:disable-next-line:no-any
|
2017-12-29 16:41:45 -07:00
|
|
|
expect(inferUpdateId((true as any))).toBe("*");
|
|
|
|
});
|
2018-01-02 08:39:40 -07:00
|
|
|
|
|
|
|
it("handles normal URLs", () => {
|
|
|
|
expect(inferUpdateId("foo/123")).toBe("123");
|
|
|
|
});
|
2017-12-29 16:41:45 -07:00
|
|
|
});
|