oav/test/utilsTests.ts

46 строки
1.7 KiB
TypeScript
Исходник Обычный вид История

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
2020-11-24 06:07:36 +03:00
import assert from "assert";
import * as utils from "../lib/util/utils";
2018-06-04 23:06:00 +03:00
describe("Utility functions", () => {
describe("Get Provider", () => {
it("should throw on empty", () => {
assert.throws(() => {
2020-11-24 06:07:36 +03:00
utils.getProvider("");
});
});
2018-06-04 23:06:00 +03:00
it("should throw null", () => {
assert.throws(() => {
2020-11-24 06:07:36 +03:00
utils.getProvider(null);
});
});
2018-06-04 23:06:00 +03:00
it("should throw undefined", () => {
assert.throws(() => {
2020-11-24 06:07:36 +03:00
utils.getProvider();
});
});
2018-06-04 23:06:00 +03:00
it("should return Microsoft.Resources", () => {
const path =
"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/" +
2020-11-24 06:07:36 +03:00
"Microsoft.Resources/{parentResourcePath}/{resourceType}/{resourceName}";
const provider = utils.getProvider(path);
assert.strictEqual(provider, "Microsoft.Resources");
});
2018-06-04 23:06:00 +03:00
it("should return undefined", () => {
2020-11-24 06:07:36 +03:00
const path = "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/";
const provider = utils.getProvider(path);
assert.strictEqual(provider, undefined);
});
2018-06-04 23:06:00 +03:00
it("should return Microsoft.Authorization", () => {
const path =
"/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/" +
"Microsoft.Resources/{parentResourcePath}/{resourceType}/{resourceName}/providers/" +
2020-11-24 06:07:36 +03:00
"Microsoft.Authorization/roleAssignments";
const provider = utils.getProvider(path);
assert.strictEqual(provider, "Microsoft.Authorization");
});
});
});