2020-07-08 10:02:47 -07:00
|
|
|
import * as Constants from "../../Common/Constants";
|
2021-04-06 14:35:14 -05:00
|
|
|
import { DatabaseAccount } from "../../Contracts/DataModels";
|
2020-11-12 13:35:39 -06:00
|
|
|
import { SubscriptionType } from "../../Contracts/SubscriptionType";
|
2021-04-06 14:35:14 -05:00
|
|
|
import { updateUserContext } from "../../UserContext";
|
2020-05-25 21:30:55 -05:00
|
|
|
import Explorer from "../Explorer";
|
|
|
|
import AddDatabasePane from "./AddDatabasePane";
|
|
|
|
|
|
|
|
describe("Add Database Pane", () => {
|
|
|
|
describe("getSharedThroughputDefault()", () => {
|
2020-07-20 12:59:40 -05:00
|
|
|
let explorer: Explorer;
|
2020-07-27 16:05:25 -05:00
|
|
|
const mockDatabaseAccount: DatabaseAccount = {
|
2020-07-08 10:02:47 -07:00
|
|
|
id: "mock",
|
|
|
|
kind: "DocumentDB",
|
|
|
|
location: "",
|
|
|
|
name: "mock",
|
|
|
|
properties: {
|
|
|
|
documentEndpoint: "",
|
|
|
|
cassandraEndpoint: "",
|
|
|
|
gremlinEndpoint: "",
|
|
|
|
tableEndpoint: "",
|
2021-01-20 09:15:01 -06:00
|
|
|
enableFreeTier: false,
|
2020-07-08 10:02:47 -07:00
|
|
|
},
|
|
|
|
type: undefined,
|
|
|
|
};
|
|
|
|
|
2020-07-27 16:05:25 -05:00
|
|
|
const mockFreeTierDatabaseAccount: DatabaseAccount = {
|
2020-07-08 10:02:47 -07:00
|
|
|
id: "mock",
|
|
|
|
kind: "DocumentDB",
|
|
|
|
location: "",
|
|
|
|
name: "mock",
|
|
|
|
properties: {
|
|
|
|
documentEndpoint: "",
|
|
|
|
cassandraEndpoint: "",
|
|
|
|
gremlinEndpoint: "",
|
|
|
|
tableEndpoint: "",
|
2021-01-20 09:15:01 -06:00
|
|
|
enableFreeTier: true,
|
2020-07-08 10:02:47 -07:00
|
|
|
},
|
|
|
|
type: undefined,
|
|
|
|
};
|
2020-05-25 21:30:55 -05:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2020-10-12 22:10:28 -05:00
|
|
|
explorer = new Explorer();
|
2020-05-25 21:30:55 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should be true if subscription type is Benefits", () => {
|
2021-04-06 14:35:14 -05:00
|
|
|
updateUserContext({
|
|
|
|
subscriptionType: SubscriptionType.Benefits,
|
|
|
|
});
|
2020-05-25 21:30:55 -05:00
|
|
|
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
|
|
|
|
expect(addDatabasePane.getSharedThroughputDefault()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should be false if subscription type is EA", () => {
|
2021-04-06 14:35:14 -05:00
|
|
|
updateUserContext({
|
|
|
|
subscriptionType: SubscriptionType.EA,
|
|
|
|
});
|
2020-05-25 21:30:55 -05:00
|
|
|
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
|
|
|
|
expect(addDatabasePane.getSharedThroughputDefault()).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should be true if subscription type is Free", () => {
|
2021-04-06 14:35:14 -05:00
|
|
|
updateUserContext({
|
|
|
|
subscriptionType: SubscriptionType.Free,
|
|
|
|
});
|
2020-05-25 21:30:55 -05:00
|
|
|
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
|
|
|
|
expect(addDatabasePane.getSharedThroughputDefault()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should be true if subscription type is Internal", () => {
|
2021-04-06 14:35:14 -05:00
|
|
|
updateUserContext({
|
|
|
|
subscriptionType: SubscriptionType.Internal,
|
|
|
|
});
|
2020-05-25 21:30:55 -05:00
|
|
|
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
|
|
|
|
expect(addDatabasePane.getSharedThroughputDefault()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should be true if subscription type is PAYG", () => {
|
2021-04-06 14:35:14 -05:00
|
|
|
updateUserContext({
|
|
|
|
subscriptionType: SubscriptionType.PAYG,
|
|
|
|
});
|
2020-05-25 21:30:55 -05:00
|
|
|
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
|
|
|
|
expect(addDatabasePane.getSharedThroughputDefault()).toBe(true);
|
|
|
|
});
|
2020-07-08 10:02:47 -07:00
|
|
|
|
|
|
|
it("should display free tier text in upsell messaging", () => {
|
|
|
|
explorer.databaseAccount(mockFreeTierDatabaseAccount);
|
|
|
|
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
|
|
|
|
expect(addDatabasePane.isFreeTierAccount()).toBe(true);
|
2021-01-04 12:56:55 -08:00
|
|
|
expect(addDatabasePane.upsellMessage()).toContain("With free tier");
|
2020-07-08 10:02:47 -07:00
|
|
|
expect(addDatabasePane.upsellAnchorUrl()).toBe(Constants.Urls.freeTierInformation);
|
|
|
|
expect(addDatabasePane.upsellAnchorText()).toBe("Learn more");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should display standard texr in upsell messaging", () => {
|
|
|
|
explorer.databaseAccount(mockDatabaseAccount);
|
|
|
|
const addDatabasePane = explorer.addDatabasePane as AddDatabasePane;
|
|
|
|
expect(addDatabasePane.isFreeTierAccount()).toBe(false);
|
|
|
|
expect(addDatabasePane.upsellMessage()).toContain("Start at");
|
|
|
|
expect(addDatabasePane.upsellAnchorUrl()).toBe(Constants.Urls.cosmosPricing);
|
|
|
|
expect(addDatabasePane.upsellAnchorText()).toBe("More details");
|
|
|
|
});
|
2020-05-25 21:30:55 -05:00
|
|
|
});
|
|
|
|
});
|