mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-21 09:51:11 +00:00
Remove Explorer.features (#563)
In addition this makes the URL-passed feature flags type safe
This commit is contained in:
@@ -1,17 +1,22 @@
|
||||
import { extractFeatures } from "./extractFeatures";
|
||||
|
||||
describe("extractFeatures", () => {
|
||||
it("correctly detects feature flags", () => {
|
||||
// Search containing non-features, with Camelcase keys and uri encoded values
|
||||
const params = new URLSearchParams(
|
||||
"?platform=Hosted&feature.notebookserverurl=https%3A%2F%2Flocalhost%3A10001%2F12345%2Fnotebook&feature.notebookServerToken=token&feature.enablenotebooks=true&key=mykey"
|
||||
);
|
||||
it("correctly detects feature flags in a case insensitive manner", () => {
|
||||
const url = "https://localhost:10001/12345/notebook";
|
||||
const token = "super secret";
|
||||
const notebooksEnabled = false;
|
||||
const params = new URLSearchParams({
|
||||
platform: "Hosted",
|
||||
"feature.NOTEBOOKSERVERURL": url,
|
||||
"feature.NoTeBooKServerToken": token,
|
||||
"feature.NotAFeature": "nope",
|
||||
"feature.ENABLEnotebooks": notebooksEnabled.toString(),
|
||||
});
|
||||
|
||||
const features = extractFeatures(params);
|
||||
|
||||
expect(features).toEqual({
|
||||
notebookserverurl: "https://localhost:10001/12345/notebook",
|
||||
notebookservertoken: "token",
|
||||
enablenotebooks: "true",
|
||||
});
|
||||
expect(features.notebookServerUrl).toBe(url);
|
||||
expect(features.notebookServerToken).toBe(token);
|
||||
expect(features.enableNotebooks).toBe(notebooksEnabled);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user