-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- setting up first unit test using chai/sinon - adding ESLint config for VSCode ### Packages impacted by this PR ### Issues associated with this PR ### Describe the problem that is addressed by this PR ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [] Added impacted package name to the issue description - [] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [] Added a changelog (if necessary)
- Loading branch information
1 parent
208f9b8
commit 0b2e7a8
Showing
3 changed files
with
70 additions
and
3 deletions.
There are no files selected for viewing
11 changes: 8 additions & 3 deletions
11
sdk/communication/communication-call-automation/.eslintrc.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
{ | ||
"plugins": ["@azure/azure-sdk"], | ||
"extends": ["plugin:@azure/azure-sdk/azure-sdk-base"], | ||
"plugins": [ | ||
"@azure/azure-sdk" | ||
], | ||
"extends": [ | ||
"plugin:@azure/azure-sdk/azure-sdk-base", | ||
"typescript" | ||
], | ||
"rules": { | ||
// Removing `src` would be a breaking change so leaving it for the package owners to address | ||
"@azure/azure-sdk/ts-package-json-files-required": "warn" | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
sdk/communication/communication-call-automation/test/public/callAutomationClient.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,50 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
import { CommunicationIdentifier } from "@azure/communication-common"; | ||
import { fail } from "assert"; | ||
import { assert } from "chai"; | ||
import Sinon, { SinonStubbedInstance } from "sinon"; | ||
import { CallAutomationClient } from "../../src/callAutomationClient"; | ||
import { CallConnection } from "../../src/callConnection"; | ||
import { CallConnectionProperties } from "../../src/models/models"; | ||
import { CreateCallResult } from "../../src/models/responses"; | ||
import { CALL_CALLBACK_URL, CALL_TARGET_ID } from "./utils/connectionUtils"; | ||
|
||
describe("Call Automation Client Unit Tests", () => { | ||
var targets: CommunicationIdentifier[]; | ||
var client: SinonStubbedInstance<CallAutomationClient> & CallAutomationClient; | ||
|
||
beforeEach(() => { | ||
// set up | ||
targets = [{ | ||
communicationUserId: CALL_TARGET_ID | ||
}]; | ||
// stub CallAutomationClient | ||
client = Sinon.createStubInstance(CallAutomationClient) as SinonStubbedInstance<CallAutomationClient> & CallAutomationClient; | ||
}); | ||
|
||
it("CreateCall", async () => { | ||
|
||
// mocks | ||
const createCallResultMock: CreateCallResult = { | ||
callConnectionProperties: {} as CallConnectionProperties, | ||
callConnection: {} as CallConnection | ||
}; | ||
client.createCall.returns(new Promise((resolve) => { | ||
resolve(createCallResultMock); | ||
})); | ||
|
||
var promiseResult = client.createCall(targets, CALL_CALLBACK_URL); | ||
|
||
// asserts | ||
promiseResult.then((result: CreateCallResult) => { | ||
assert.isNotNull(result); | ||
assert.isTrue(client.createCall.calledWith(targets, CALL_CALLBACK_URL)); | ||
assert.equal(result, createCallResultMock); | ||
}).catch((reject) => { | ||
fail(reject); // should not reach here | ||
}); | ||
}); | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters