mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-16 17:25:58 +00:00
* Add additional teaching bubbles in Quickstart * Run npm format * Fix lint error * Add unit tests * Add Mongo teaching bubbles for Try CosmosDB and Launch full screen * Add additional tests for UrlUtility * Run npm format * Add tests for Notebook Utils
85 lines
2.2 KiB
TypeScript
85 lines
2.2 KiB
TypeScript
import { OfferResponse } from "@azure/cosmos";
|
|
import { Offer, SDKOfferDefinition } from "../Contracts/DataModels";
|
|
import * as OfferUtility from "./OfferUtility";
|
|
|
|
describe("parseSDKOfferResponse", () => {
|
|
it("manual throughput", () => {
|
|
const mockOfferDefinition = {
|
|
content: {
|
|
offerThroughput: 500,
|
|
collectionThroughputInfo: {
|
|
minimumRUForCollection: 400,
|
|
numPhysicalPartitions: 1,
|
|
},
|
|
},
|
|
id: "test",
|
|
} as SDKOfferDefinition;
|
|
|
|
const mockResponse = {
|
|
resource: mockOfferDefinition,
|
|
} as OfferResponse;
|
|
|
|
const expectedResult: Offer = {
|
|
manualThroughput: 500,
|
|
autoscaleMaxThroughput: undefined,
|
|
minimumThroughput: 400,
|
|
id: "test",
|
|
offerDefinition: mockOfferDefinition,
|
|
offerReplacePending: false,
|
|
};
|
|
|
|
expect(OfferUtility.parseSDKOfferResponse(mockResponse)).toEqual(expectedResult);
|
|
});
|
|
|
|
it("offerContent not defined", () => {
|
|
const mockOfferDefinition = {
|
|
id: "test",
|
|
} as SDKOfferDefinition;
|
|
|
|
const mockResponse = {
|
|
resource: mockOfferDefinition,
|
|
} as OfferResponse;
|
|
|
|
expect(OfferUtility.parseSDKOfferResponse(mockResponse)).toEqual(undefined);
|
|
});
|
|
|
|
it("offerDefinition is null", () => {
|
|
const mockResponse = {
|
|
resource: undefined,
|
|
} as OfferResponse;
|
|
|
|
expect(OfferUtility.parseSDKOfferResponse(mockResponse)).toEqual(undefined);
|
|
});
|
|
|
|
it("autoscale throughput", () => {
|
|
const mockOfferDefinition = {
|
|
content: {
|
|
offerThroughput: 400,
|
|
collectionThroughputInfo: {
|
|
minimumRUForCollection: 400,
|
|
numPhysicalPartitions: 1,
|
|
},
|
|
offerAutopilotSettings: {
|
|
maxThroughput: 5000,
|
|
},
|
|
},
|
|
id: "test",
|
|
} as SDKOfferDefinition;
|
|
|
|
const mockResponse = {
|
|
resource: mockOfferDefinition,
|
|
} as OfferResponse;
|
|
|
|
const expectedResult: Offer = {
|
|
manualThroughput: undefined,
|
|
autoscaleMaxThroughput: 5000,
|
|
minimumThroughput: 400,
|
|
id: "test",
|
|
offerDefinition: mockOfferDefinition,
|
|
offerReplacePending: false,
|
|
};
|
|
|
|
expect(OfferUtility.parseSDKOfferResponse(mockResponse)).toEqual(expectedResult);
|
|
});
|
|
});
|