2020-05-25 21:30:55 -05:00
|
|
|
import * as Constants from "../../Common/Constants";
|
|
|
|
import AddCollectionPane from "./AddCollectionPane";
|
|
|
|
import Explorer from "../Explorer";
|
2020-10-29 11:26:37 -05:00
|
|
|
import { DatabaseAccount } from "../../Contracts/DataModels";
|
2020-05-25 21:30:55 -05:00
|
|
|
|
|
|
|
describe("Add Collection Pane", () => {
|
|
|
|
describe("isValid()", () => {
|
2020-07-20 12:59:40 -05:00
|
|
|
let explorer: Explorer;
|
2020-07-27 16:05:25 -05:00
|
|
|
const mockDatabaseAccount: DatabaseAccount = {
|
2020-05-25 21:30:55 -05:00
|
|
|
id: "mock",
|
|
|
|
kind: "DocumentDB",
|
|
|
|
location: "",
|
|
|
|
name: "mock",
|
2020-07-08 10:02:47 -07:00
|
|
|
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,
|
2021-01-20 09:15:01 -06:00
|
|
|
tags: [],
|
2020-07-08 10:02:47 -07:00
|
|
|
};
|
|
|
|
|
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
|
|
|
},
|
2020-05-25 21:30:55 -05:00
|
|
|
type: undefined,
|
2021-01-20 09:15:01 -06:00
|
|
|
tags: [],
|
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 graph API and partition key is not /id nor /label", () => {
|
|
|
|
explorer.defaultExperience(Constants.DefaultAccountExperience.Graph.toLowerCase());
|
|
|
|
const addCollectionPane = explorer.addCollectionPane as AddCollectionPane;
|
|
|
|
addCollectionPane.partitionKey("/blah");
|
|
|
|
expect(addCollectionPane.isValid()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should be false if graph API and partition key is /id or /label", () => {
|
|
|
|
explorer.defaultExperience(Constants.DefaultAccountExperience.Graph.toLowerCase());
|
|
|
|
const addCollectionPane = explorer.addCollectionPane as AddCollectionPane;
|
|
|
|
addCollectionPane.partitionKey("/id");
|
|
|
|
expect(addCollectionPane.isValid()).toBe(false);
|
|
|
|
|
|
|
|
addCollectionPane.partitionKey("/label");
|
|
|
|
expect(addCollectionPane.isValid()).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should be true for any non-graph API with /id or /label partition key", () => {
|
|
|
|
explorer.defaultExperience(Constants.DefaultAccountExperience.DocumentDB.toLowerCase());
|
|
|
|
const addCollectionPane = explorer.addCollectionPane as AddCollectionPane;
|
|
|
|
|
|
|
|
addCollectionPane.partitionKey("/id");
|
|
|
|
expect(addCollectionPane.isValid()).toBe(true);
|
|
|
|
|
|
|
|
addCollectionPane.partitionKey("/label");
|
|
|
|
expect(addCollectionPane.isValid()).toBe(true);
|
|
|
|
});
|
2020-07-08 10:02:47 -07:00
|
|
|
|
|
|
|
it("should display free tier text in upsell messaging", () => {
|
|
|
|
explorer.databaseAccount(mockFreeTierDatabaseAccount);
|
|
|
|
const addCollectionPane = explorer.addCollectionPane as AddCollectionPane;
|
|
|
|
expect(addCollectionPane.isFreeTierAccount()).toBe(true);
|
2021-01-04 12:56:55 -08:00
|
|
|
expect(addCollectionPane.upsellMessage()).toContain("With free tier");
|
2020-07-08 10:02:47 -07:00
|
|
|
expect(addCollectionPane.upsellAnchorUrl()).toBe(Constants.Urls.freeTierInformation);
|
|
|
|
expect(addCollectionPane.upsellAnchorText()).toBe("Learn more");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should display standard texr in upsell messaging", () => {
|
|
|
|
explorer.databaseAccount(mockDatabaseAccount);
|
|
|
|
const addCollectionPane = explorer.addCollectionPane as AddCollectionPane;
|
|
|
|
expect(addCollectionPane.isFreeTierAccount()).toBe(false);
|
|
|
|
expect(addCollectionPane.upsellMessage()).toContain("Start at");
|
|
|
|
expect(addCollectionPane.upsellAnchorUrl()).toBe(Constants.Urls.cosmosPricing);
|
|
|
|
expect(addCollectionPane.upsellAnchorText()).toBe("More details");
|
|
|
|
});
|
2020-05-25 21:30:55 -05:00
|
|
|
});
|
|
|
|
});
|