Skip to content
Closed
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/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
@@ -0,0 +1,21 @@
Copyright (c) Microsoft Corporation.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Azure Parent client library for JavaScript

This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure Parent client.

Test for client initialization decorator - moving parameters from method to client level

Key links:

- [Package (NPM)](https://www.npmjs.com/package/@azure/client-generator-core-initialization)
- [API reference documentation](https://learn.microsoft.com/javascript/api/@azure/client-generator-core-initialization?view=azure-node-preview)

## Getting started

### Currently supported environments

- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
- Latest versions of Safari, Chrome, Edge and Firefox.

See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.

### Prerequisites

- An [Azure subscription][azure_sub].

### Install the `@azure/client-generator-core-initialization` package

Install the Azure Parent client library for JavaScript with `npm`:

```bash
npm install @azure/client-generator-core-initialization
```



### JavaScript Bundle
To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling).

## Key concepts

### ParentClient

`ParentClient` is the primary interface for developers using the Azure Parent client library. Explore the methods on this client object to understand the different features of the Azure Parent service that you can access.

## Troubleshooting

### Logging

Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:

```ts
import { setLogLevel } from "@azure/logger";

setLogLevel("info");
```

For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).


## Contributing

If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.

## Related projects

- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js)

[azure_sub]: https://azure.microsoft.com/free/
[azure_portal]: https://portal.azure.com
[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity
[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential
Loading
Loading