forked from microsoft/typespec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.test.ts
31 lines (27 loc) · 1019 Bytes
/
utils.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { describe, expect, it } from "vitest";
import { extractParamsFromPath } from "../src/utils.js";
describe("utils", () => {
describe("extractParamsFromPath", () => {
it("parse single param", () => {
expect(extractParamsFromPath("foo/{name}/bar")).toEqual(["name"]);
});
it("parse param with -", () => {
expect(extractParamsFromPath("foo/{foo-bar}/bar")).toEqual(["foo-bar"]);
});
it("parse multiple param", () => {
expect(extractParamsFromPath("foo/{name}/bar/{age}")).toEqual(["name", "age"]);
});
it("parse single OData params", () => {
expect(extractParamsFromPath("/certificates(thumbprint={thumbprint})/canceldelete")).toEqual([
"thumbprint",
]);
});
it("parse multiple OData params", () => {
expect(
extractParamsFromPath(
"/certificates(thumbprintAlgorithm={thumbprintAlgorithm},thumbprint={thumbprint})/canceldelete"
)
).toEqual(["thumbprintAlgorithm", "thumbprint"]);
});
});
});