Move read offer to RP (#326)

This commit is contained in:
victor-meng
2020-11-19 17:13:11 -08:00
committed by GitHub
parent a93c8509cd
commit 17fd2185dc
29 changed files with 406 additions and 742 deletions

View File

@@ -7,15 +7,6 @@ export const minAutoPilotThroughput = 4000;
export const autoPilotIncrementStep = 1000;
export function isValidV3AutoPilotOffer(offer: Offer): boolean {
const maxThroughput =
offer &&
offer.content &&
offer.content.offerAutopilotSettings &&
offer.content.offerAutopilotSettings.maxThroughput;
return isValidAutoPilotThroughput(maxThroughput);
}
export function isValidAutoPilotThroughput(maxThroughput: number): boolean {
if (!maxThroughput) {
return false;

View File

@@ -1,51 +0,0 @@
import * as Constants from "../../src/Common/Constants";
import * as DataModels from "../../src/Contracts/DataModels";
import { OfferUtils } from "../../src/Utils/OfferUtils";
describe("OfferUtils tests", () => {
const offerV1: DataModels.Offer = {
_rid: "",
_self: "",
_ts: 0,
_etag: "",
id: "v1",
offerVersion: Constants.OfferVersions.V1,
offerType: "Standard",
offerResourceId: "",
content: null,
resource: ""
};
const offerV2: DataModels.Offer = {
_rid: "",
_self: "",
_ts: 0,
_etag: "",
id: "v1",
offerVersion: Constants.OfferVersions.V2,
offerType: "Standard",
offerResourceId: "",
content: null,
resource: ""
};
describe("isOfferV1()", () => {
it("should return true for V1", () => {
expect(OfferUtils.isOfferV1(offerV1)).toBeTruthy();
});
it("should return false for V2", () => {
expect(OfferUtils.isOfferV1(offerV2)).toBeFalsy();
});
});
describe("isNotOfferV1()", () => {
it("should return true for V2", () => {
expect(OfferUtils.isNotOfferV1(offerV2)).toBeTruthy();
});
it("should return false for V1", () => {
expect(OfferUtils.isNotOfferV1(offerV1)).toBeFalsy();
});
});
});

View File

@@ -1,12 +0,0 @@
import * as Constants from "../Common/Constants";
import * as DataModels from "../Contracts/DataModels";
export class OfferUtils {
public static isOfferV1(offer: DataModels.Offer): boolean {
return !offer || offer.offerVersion !== Constants.OfferVersions.V2;
}
public static isNotOfferV1(offer: DataModels.Offer): boolean {
return !OfferUtils.isOfferV1(offer);
}
}