Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/typespec-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"integration-test:alone:rlc": "cross-env TS_NODE_PROJECT=tsconfig.integration.json mocha -r ts-node/register --experimental-specifier-resolution=node --timeout 36000 ./test/integration/*.spec.ts",
"integration-test:alone:azure-rlc": "cross-env TS_NODE_PROJECT=tsconfig.integration.json mocha -r ts-node/register --experimental-specifier-resolution=node --timeout 36000 ./test/azureIntegration/*.spec.ts",
"integration-test:alone:modular": "cross-env TS_NODE_PROJECT=tsconfig.integration.json mocha -r ts-node/register --experimental-specifier-resolution=node --timeout 36000 ./test/modularIntegration/*.spec.ts",
"integration-test:alone:azure-modular": "cross-env TS_NODE_PROJECT=tsconfig.integration.json mocha -r ts-node/register --experimental-specifier-resolution=node --timeout 36000 ./test/azureModularIntegration/*.spec.ts",
"integration-test:alone:azure-modular": "cross-env TS_NODE_PROJECT=tsconfig.integration.json mocha -r ts-node/register --experimental-specifier-resolution=node --timeout 36000 ./test/azureModularIntegration/azureClientGeneratorCoreClientInitialization.spec.ts",
"stop-test-server": "npx tsp-spector server stop",
"unit-test": "npm-run-all --parallel unit-test:rlc unit-test:modular",
"unit-test:rlc": "cross-env TS_NODE_PROJECT=tsconfig.json mocha -r ts-node/register --experimental-specifier-resolution=node --experimental-modules=true --timeout 36000 './test/unit/**/*.spec.ts'",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,151 +1,146 @@
import { assert } from "chai";
import {
HeaderParamClient,
MultipleParamsClient,
MixedParamsClient,
PathParamClient,
ParamAliasClient,
ParentClient
} from "./generated/azure/client-generator-core/client-initialization/src/index.js";
IndividuallyParentNestedWithHeaderClient,
IndividuallyParentNestedWithMixedClient,
IndividuallyParentNestedWithMultipleClient,
IndividuallyParentNestedWithPathClient,
IndividuallyParentNestedWithQueryClient
} from "./generated/azure/client-generator-core/client-initialization/default/individuallyParent/src/index.js";

describe("Azure ClientGeneratorCore Client Initialization", () => {
const endpointOptions = {
endpoint: "http://localhost:3002",
allowInsecureConnection: true
};

describe("HeaderParam Client", () => {
let client: HeaderParamClient;

beforeEach(() => {
client = new HeaderParamClient("test-name-value", endpointOptions);
});

it("should send header parameter in withQuery operation", async () => {
const result = await client.withQuery("test-id");
assert.isUndefined(result);
});

it("should send header parameter in withBody operation", async () => {
const result = await client.withBody({ name: "test-name" });
assert.isUndefined(result);
});
});

describe("MultipleParams Client", () => {
let client: MultipleParamsClient;

beforeEach(() => {
client = new MultipleParamsClient(
"test-name-value",
"us-west",
endpointOptions
);
});

it("should send multiple parameters in withQuery operation", async () => {
const result = await client.withQuery("test-id");
assert.isUndefined(result);
});

it("should send multiple parameters in withBody operation", async () => {
const result = await client.withBody({ name: "test-name" });
assert.isUndefined(result);
});
});

describe("MixedParams Client", () => {
let client: MixedParamsClient;

beforeEach(() => {
client = new MixedParamsClient("test-name-value", endpointOptions);
});

it("should send mixed parameters in withQuery operation", async () => {
const result = await client.withQuery("us-west", "test-id");
assert.isUndefined(result);
});

it("should send mixed parameters in withBody operation", async () => {
const result = await client.withBody("us-west", { name: "test-name" });
assert.isUndefined(result);
});
});

describe("PathParam Client", () => {
let client: PathParamClient;

beforeEach(() => {
client = new PathParamClient("sample-blob", endpointOptions);
});

it("should send path parameter in withQuery operation", async () => {
const result = await client.withQuery({ format: "text" });
assert.isUndefined(result);
});

it("should get standalone with path parameter", async () => {
const result = await client.getStandalone();
assert.strictEqual(result.name, "sample-blob");
assert.strictEqual(result.size, 42);
assert.strictEqual(result.contentType, "text/plain");
assert.strictEqual(
result.createdOn.toISOString(),
"2025-04-01T12:00:00.000Z"
);
});

it("should delete standalone with path parameter", async () => {
const result = await client.deleteStandalone();
assert.isUndefined(result);
});
});

describe("ParamAlias Client", () => {
let client: ParamAliasClient;

beforeEach(() => {
client = new ParamAliasClient("sample-blob", endpointOptions);
});

it("should call withOriginalName operation", async () => {
const result = await client.withOriginalName();
assert.isUndefined(result);
});

it("should call withAliasedName operation", async () => {
const result = await client.withAliasedName();
assert.isUndefined(result);
});
});

describe("Parent-Child Client", () => {
let parentClient: ParentClient;

beforeEach(() => {
parentClient = new ParentClient(endpointOptions);
});

it("should create child client and perform operations", async () => {
const childClient = parentClient.getChildClient("sample-blob");

// Test withQuery operation
const queryResult = await childClient.withQuery({ format: "text" });
assert.isUndefined(queryResult);

// Test getStandalone operation
const getResult = await childClient.getStandalone();
assert.strictEqual(getResult.name, "sample-blob");
assert.strictEqual(getResult.size, 42);
assert.strictEqual(getResult.contentType, "text/plain");
assert.strictEqual(
getResult.createdOn.toISOString(),
"2025-04-01T12:00:00.000Z"
);

// Test deleteStandalone operation
const deleteResult = await childClient.deleteStandalone();
assert.isUndefined(deleteResult);
describe("IndividuallyParent Client Tests", () => {
describe("Specialized Nested Clients", () => {
describe("IndividuallyParentNestedWithHeaderClient", () => {
let client: IndividuallyParentNestedWithHeaderClient;

beforeEach(() => {
client = new IndividuallyParentNestedWithHeaderClient("test-name-value", endpointOptions);
});

it("should send nested header parameter in withQuery operation", async () => {
const result = await client.withQuery({ format: "text" });
assert.isUndefined(result);
});

it("should get standalone with nested header parameter", async () => {
const result = await client.getStandalone();
assert.isUndefined(result);
});

it("should delete standalone with nested header parameter", async () => {
const result = await client.deleteStandalone();
assert.isUndefined(result);
});
});

describe("IndividuallyParentNestedWithMultipleClient", () => {
let client: IndividuallyParentNestedWithMultipleClient;

beforeEach(() => {
client = new IndividuallyParentNestedWithMultipleClient("test-name-value", "us-west", endpointOptions);
});

it("should send nested multiple parameters in withQuery operation", async () => {
const result = await client.withQuery({ format: "text" });
assert.isUndefined(result);
});

it("should get standalone with nested multiple parameters", async () => {
const result = await client.getStandalone();
assert.isUndefined(result);
});

it("should delete standalone with nested multiple parameters", async () => {
const result = await client.deleteStandalone();
assert.isUndefined(result);
});
});

describe("IndividuallyParentNestedWithMixedClient", () => {
let client: IndividuallyParentNestedWithMixedClient;

beforeEach(() => {
client = new IndividuallyParentNestedWithMixedClient("test-name-value", endpointOptions);
});

it("should send nested mixed parameters in withQuery operation", async () => {
const result = await client.withQuery("us-west", { format: "text" });
assert.isUndefined(result);
});

it("should get standalone with nested mixed parameters", async () => {
const result = await client.getStandalone("us-west");
assert.isUndefined(result);
});

it("should delete standalone with nested mixed parameters", async () => {
const result = await client.deleteStandalone("us-west");
assert.isUndefined(result);
});
});

describe("IndividuallyParentNestedWithPathClient", () => {
let client: IndividuallyParentNestedWithPathClient;

beforeEach(() => {
client = new IndividuallyParentNestedWithPathClient("test-resource", endpointOptions);
});

it("should send nested path parameter in withQuery operation", async () => {
const result = await client.withQuery({ format: "text" });
assert.isUndefined(result);
});

it("should get standalone with nested path parameter", async () => {
const result = await client.getStandalone();
assert.strictEqual(result.name, "test-resource");
assert.strictEqual(result.size, 1024);
assert.strictEqual(result.contentType, "application/octet-stream");
assert.strictEqual(
result.createdOn.toISOString(),
"2023-01-01T12:00:00.000Z"
);
});

it("should delete standalone with nested path parameter", async () => {
const result = await client.deleteStandalone();
assert.isUndefined(result);
});
});

describe("IndividuallyParentNestedWithQueryClient", () => {
let client: IndividuallyParentNestedWithQueryClient;

beforeEach(() => {
client = new IndividuallyParentNestedWithQueryClient("test-blob", endpointOptions);
});

it("should send nested query parameter in withQuery operation", async () => {
const result = await client.withQuery();
assert.isUndefined(result);
});

it("should get standalone with nested query parameter", async () => {
const result = await client.getStandalone();
assert.strictEqual(result.name, "test-blob");
assert.strictEqual(result.size, 1024);
assert.strictEqual(result.contentType, "application/octet-stream");
assert.strictEqual(
result.createdOn.toISOString(),
"2023-01-01T12:00:00.000Z"
);
});

it("should delete standalone with nested query parameter", async () => {
const result = await client.deleteStandalone();
assert.isUndefined(result);
});
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,6 @@ export declare interface BlobProperties {
createdOn: Date;
}

export declare class ChildClient {
private _client;
readonly pipeline: Pipeline;
constructor(blobName: string, options?: ChildClientOptionalParams);
deleteStandalone(options?: ChildClientDeleteStandaloneOptionalParams): Promise<void>;
getStandalone(options?: ChildClientGetStandaloneOptionalParams): Promise<BlobProperties>;
withQuery(options?: ChildClientWithQueryOptionalParams): Promise<void>;
}

export declare interface ChildClientDeleteStandaloneOptionalParams extends OperationOptions {
}

export declare interface ChildClientGetStandaloneOptionalParams extends OperationOptions {
}

export declare interface ChildClientOptionalParams extends ClientOptions {
}

export declare interface ChildClientWithQueryOptionalParams extends OperationOptions {
format?: string;
}

export declare interface DeleteStandaloneOptionalParams extends OperationOptions {
}

Expand Down Expand Up @@ -99,17 +77,6 @@ export declare class ParamAliasClient {
export declare interface ParamAliasClientOptionalParams extends ClientOptions {
}

export declare class ParentClient {
private _client;
readonly pipeline: Pipeline;
private _clientParams;
constructor(options?: ParentClientOptionalParams);
getChildClient(blobName: string, options?: ChildClientOptionalParams): ChildClient;
}

export declare interface ParentClientOptionalParams extends ClientOptions {
}

export declare class PathParamClient {
private _client;
readonly pipeline: Pipeline;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
!/src
/src/**
!/src/index.d.ts
!/.gitignore
!/tspconfig.yaml
Loading
Loading