[communication] Migrate @azure/communication-phone-numbers to ESM/vitest (#31734)
### Packages impacted by this PR - @azure/communication-phone-numbers ### Issues associated with this PR - https://github.com/Azure/azure-sdk-for-js/issues/31338 ### Describe the problem that is addressed by this PR Upgrades @azure/communication-phone-numbers to use ESM and vitest. ### 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)
This commit is contained in:
Родитель
65e1e5c14e
Коммит
b2bb3e6c90
|
@ -18898,7 +18898,7 @@ packages:
|
|||
dev: false
|
||||
|
||||
file:projects/communication-phone-numbers.tgz:
|
||||
resolution: {integrity: sha512-TFOWK46fB+Xt/4wne7rUVXbFOJLR6FWn9+hUo1Q09WA/LTL5CyTfC1fPK7dpdGPR2OA/+ebefNQjguLcLvR2BQ==, tarball: file:projects/communication-phone-numbers.tgz}
|
||||
resolution: {integrity: sha512-kRnm7dSlOcUN3BpxBqb6K3cAum4jdmmU4BdQ4o+BaHcS7s6yWImkZL4vKz0ELMgUSCSLu4w2FqV5XinSAg4eeA==, tarball: file:projects/communication-phone-numbers.tgz}
|
||||
name: '@rush-temp/communication-phone-numbers'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
|
@ -18909,6 +18909,8 @@ packages:
|
|||
'@types/mocha': 10.0.9
|
||||
'@types/node': 18.19.64
|
||||
'@types/sinon': 17.0.3
|
||||
'@vitest/browser': 2.1.4(@types/node@18.19.64)(playwright@1.48.2)(typescript@5.6.3)(vitest@2.1.4)
|
||||
'@vitest/coverage-istanbul': 2.1.4(vitest@2.1.4)
|
||||
chai: 4.3.10
|
||||
dotenv: 16.4.5
|
||||
eslint: 9.14.0
|
||||
|
@ -18925,22 +18927,36 @@ packages:
|
|||
karma-sourcemap-loader: 0.3.8
|
||||
mocha: 10.8.2
|
||||
nyc: 17.1.0
|
||||
playwright: 1.48.2
|
||||
sinon: 17.0.1
|
||||
ts-node: 10.9.2(@types/node@18.19.64)(typescript@5.6.3)
|
||||
tslib: 2.8.1
|
||||
typescript: 5.6.3
|
||||
vitest: 2.1.4(@types/node@18.19.64)(@vitest/browser@2.1.4)
|
||||
transitivePeerDependencies:
|
||||
- '@swc/core'
|
||||
- '@swc/wasm'
|
||||
- '@edge-runtime/vm'
|
||||
- '@vitest/ui'
|
||||
- bufferutil
|
||||
- debug
|
||||
- happy-dom
|
||||
- jiti
|
||||
- jsdom
|
||||
- less
|
||||
- lightningcss
|
||||
- msw
|
||||
- safaridriver
|
||||
- sass
|
||||
- sass-embedded
|
||||
- stylus
|
||||
- sugarss
|
||||
- supports-color
|
||||
- terser
|
||||
- utf-8-validate
|
||||
- vite
|
||||
- webdriverio
|
||||
dev: false
|
||||
|
||||
file:projects/communication-recipient-verification.tgz:
|
||||
resolution: {integrity: sha512-oMQJoVgxh+OHiDBs3Cn7Mh/6P27eKJ5NOB6TSeIzyKaC4SVIggPi/SjtU1eSEgcVqOetzZ1Cikqhf9gKYb3hDg==, tarball: file:projects/communication-recipient-verification.tgz}
|
||||
resolution: {integrity: sha512-cpVMuIbO+tSFbjQSjDB1yOL3QgqBKppbLvWuYCe2JoY10LBIu+a5SWMTSk9DbjlN+DfUCQ8gQN01zbizH0BBhw==, tarball: file:projects/communication-recipient-verification.tgz}
|
||||
name: '@rush-temp/communication-recipient-verification'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"include": ["dist-esm/src/**/*.js"],
|
||||
"exclude": ["**/*.d.ts", "dist-esm/src/generated/*"],
|
||||
"reporter": ["text-summary", "html", "cobertura"],
|
||||
"exclude-after-remap": false,
|
||||
"sourceMap": true,
|
||||
"produce-source-map": true,
|
||||
"instrument": true,
|
||||
"all": true
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
"mainEntryPointFilePath": "types/src/index.d.ts",
|
||||
"mainEntryPointFilePath": "dist/esm/index.d.ts",
|
||||
"docModel": {
|
||||
"enabled": true
|
||||
},
|
||||
|
@ -11,7 +11,7 @@
|
|||
"dtsRollup": {
|
||||
"enabled": true,
|
||||
"untrimmedFilePath": "",
|
||||
"publicTrimmedFilePath": "./types/communication-phone-numbers.d.ts"
|
||||
"publicTrimmedFilePath": "dist/communication-phone-numbers.d.ts"
|
||||
},
|
||||
"messages": {
|
||||
"tsdocMessageReporting": {
|
||||
|
|
|
@ -1,142 +0,0 @@
|
|||
// https://github.com/karma-runner/karma-chrome-launcher
|
||||
process.env.CHROME_BIN = require("puppeteer").executablePath();
|
||||
require("dotenv").config();
|
||||
const { relativeRecordingsPath } = require("@azure-tools/test-recorder");
|
||||
|
||||
process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();
|
||||
|
||||
// Get all variables containing the available phone numbers per test agent.
|
||||
// E.g. -> AZURE_PHONE_NUMBER_windows_2019_node12
|
||||
const getPhoneNumberPoolEnvVars = () => {
|
||||
return Object.keys(process.env).filter((key) => key.startsWith("AZURE_PHONE_NUMBER_"));
|
||||
};
|
||||
|
||||
module.exports = function (config) {
|
||||
config.set({
|
||||
// base path that will be used to resolve all patterns (eg. files, exclude)
|
||||
basePath: "./",
|
||||
|
||||
// frameworks to use
|
||||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
|
||||
frameworks: ["mocha"],
|
||||
|
||||
plugins: [
|
||||
"karma-mocha",
|
||||
"karma-mocha-reporter",
|
||||
"karma-chrome-launcher",
|
||||
"karma-firefox-launcher",
|
||||
"karma-env-preprocessor",
|
||||
"karma-coverage",
|
||||
"karma-sourcemap-loader",
|
||||
"karma-junit-reporter",
|
||||
],
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files: ["dist-test/index.browser.js"],
|
||||
|
||||
// list of files / patterns to exclude
|
||||
exclude: [],
|
||||
|
||||
// preprocess matching files before serving them to the browser
|
||||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
||||
preprocessors: {
|
||||
"**/*.js": ["sourcemap", "env"],
|
||||
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
|
||||
// Preprocess source file to calculate code coverage, however this will make source file unreadable
|
||||
//"dist-test/index.browser.js": ["coverage"]
|
||||
},
|
||||
|
||||
// inject following environment values into browser testing with window.__env__
|
||||
// environment values MUST be exported or set with same console running "karma start"
|
||||
// https://www.npmjs.com/package/karma-env-preprocessor
|
||||
envPreprocessor: [
|
||||
"TEST_MODE",
|
||||
"COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING",
|
||||
"COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING",
|
||||
"INCLUDE_PHONENUMBER_LIVE_TESTS",
|
||||
"AZURE_PHONE_NUMBER",
|
||||
"COMMUNICATION_ENDPOINT",
|
||||
"AZURE_CLIENT_ID",
|
||||
"AZURE_CLIENT_SECRET",
|
||||
"AZURE_TENANT_ID",
|
||||
"COMMUNICATION_SKIP_INT_PHONENUMBERS_TESTS",
|
||||
"SKIP_UPDATE_CAPABILITIES_LIVE_TESTS",
|
||||
"AZURE_TEST_AGENT",
|
||||
"AZURE_USERAGENT_OVERRIDE",
|
||||
"RECORDINGS_RELATIVE_PATH",
|
||||
"AZURE_TEST_DOMAIN",
|
||||
...getPhoneNumberPoolEnvVars(),
|
||||
],
|
||||
|
||||
// test results reporter to use
|
||||
// possible values: 'dots', 'progress'
|
||||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
||||
reporters: ["mocha", "coverage", "junit"],
|
||||
|
||||
coverageReporter: {
|
||||
// specify a common output directory
|
||||
dir: "coverage-browser/",
|
||||
reporters: [
|
||||
{ type: "json", subdir: ".", file: "coverage.json" },
|
||||
{ type: "lcovonly", subdir: ".", file: "lcov.info" },
|
||||
{ type: "html", subdir: "html" },
|
||||
{ type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" },
|
||||
],
|
||||
},
|
||||
|
||||
junitReporter: {
|
||||
outputDir: "", // results will be saved as $outputDir/$browserName.xml
|
||||
outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile
|
||||
suite: "", // suite will become the package name attribute in xml testsuite element
|
||||
useBrowserName: false, // add browser name to report and classes names
|
||||
nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
|
||||
classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
|
||||
properties: {}, // key value pair of properties to add to the <properties> section of the report
|
||||
},
|
||||
|
||||
// web server port
|
||||
port: 9876,
|
||||
|
||||
// enable / disable colors in the output (reporters and logs)
|
||||
colors: true,
|
||||
|
||||
// level of logging
|
||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||
logLevel: config.LOG_INFO,
|
||||
|
||||
// enable / disable watching file and executing tests whenever any file changes
|
||||
autoWatch: false,
|
||||
|
||||
// start these browsers
|
||||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
|
||||
// 'ChromeHeadless', 'Chrome', 'Firefox', 'Edge', 'IE'
|
||||
browsers: ["HeadlessChrome"],
|
||||
|
||||
customLaunchers: {
|
||||
HeadlessChrome: {
|
||||
base: "ChromeHeadless",
|
||||
flags: ["--no-sandbox", "--disable-web-security"],
|
||||
},
|
||||
},
|
||||
|
||||
// Continuous Integration mode
|
||||
// if true, Karma captures browsers, runs the tests and exits
|
||||
singleRun: true,
|
||||
|
||||
// Concurrency level
|
||||
// how many browser should be started simultaneous
|
||||
concurrency: 1,
|
||||
|
||||
browserNoActivityTimeout: 600000,
|
||||
browserDisconnectTimeout: 10000,
|
||||
browserDisconnectTolerance: 3,
|
||||
|
||||
client: {
|
||||
mocha: {
|
||||
// change Karma's debug.html to the mocha web reporter
|
||||
reporter: "html",
|
||||
timeout: "600000",
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
|
@ -3,24 +3,24 @@
|
|||
"version": "1.3.0-beta.4",
|
||||
"description": "SDK for Azure Communication service which facilitates phone number management.",
|
||||
"sdk-type": "client",
|
||||
"main": "dist/index.js",
|
||||
"module": "dist-esm/src/index.js",
|
||||
"types": "types/communication-phone-numbers.d.ts",
|
||||
"main": "./dist/commonjs/index.js",
|
||||
"module": "./dist/esm/index.js",
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "npm run clean && tsc -p . && dev-tool run bundle && dev-tool run extract-api",
|
||||
"build": "npm run clean && dev-tool run build-package && dev-tool run extract-api",
|
||||
"build:clean": "rush update --recheck && rush rebuild && dev-tool run build",
|
||||
"build:samples": "echo Obsolete.",
|
||||
"build:test": "tsc -p . && dev-tool run bundle",
|
||||
"build:test": "dev-tool run build-package && dev-tool run bundle",
|
||||
"bundle": "dev-tool run bundle",
|
||||
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
||||
"clean": "dev-tool run vendored rimraf --glob dist dist-* temp types *.tgz *.log",
|
||||
"execute:samples": "dev-tool samples run samples-dev",
|
||||
"extract-api": "tsc -p . && dev-tool run extract-api",
|
||||
"extract-api": "dev-tool run build-package && dev-tool run extract-api",
|
||||
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
||||
"generate:client": "autorest --typescript ./swagger/README.md && rushx format",
|
||||
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
|
||||
"integration-test:browser": "dev-tool run test:browser",
|
||||
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 5000000 'dist-esm/test/**/*.spec.js'",
|
||||
"integration-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser",
|
||||
"integration-test:node": "dev-tool run test:vitest",
|
||||
"lint": "eslint package.json api-extractor.json README.md src test",
|
||||
"lint:fix": "eslint package.json api-extractor.json README.md src test --fix --fix-type [problem,suggestion]",
|
||||
"pack": "npm pack 2>&1",
|
||||
|
@ -29,14 +29,12 @@
|
|||
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
|
||||
"test:watch": "npm run test -- --watch --reporter min",
|
||||
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
|
||||
"unit-test:browser": "dev-tool run test:browser",
|
||||
"unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'",
|
||||
"unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser",
|
||||
"unit-test:node": "dev-tool run test:vitest",
|
||||
"update-snippets": "echo skipped"
|
||||
},
|
||||
"files": [
|
||||
"dist/",
|
||||
"dist-esm/src/",
|
||||
"types/communication-phone-numbers.d.ts",
|
||||
"README.md",
|
||||
"LICENSE"
|
||||
],
|
||||
|
@ -59,7 +57,7 @@
|
|||
"prettier": "@azure/eslint-plugin-azure-sdk/prettier.json",
|
||||
"dependencies": {
|
||||
"@azure/abort-controller": "^2.0.0",
|
||||
"@azure/communication-common": "^2.2.0",
|
||||
"@azure/communication-common": "^2.3.1",
|
||||
"@azure/core-auth": "^1.3.0",
|
||||
"@azure/core-client": "^1.5.0",
|
||||
"@azure/core-lro": "^2.2.4",
|
||||
|
@ -72,34 +70,20 @@
|
|||
"tslib": "^2.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@azure-tools/test-credential": "^1.0.0",
|
||||
"@azure-tools/test-recorder": "^3.0.0",
|
||||
"@azure-tools/test-utils": "^1.0.1",
|
||||
"@azure-tools/test-credential": "^2.0.0",
|
||||
"@azure-tools/test-recorder": "^4.1.0",
|
||||
"@azure-tools/test-utils-vitest": "^1.0.0",
|
||||
"@azure/dev-tool": "^1.0.0",
|
||||
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
|
||||
"@azure/identity": "^4.0.1",
|
||||
"@types/chai": "^4.1.6",
|
||||
"@types/mocha": "^10.0.0",
|
||||
"@types/node": "^18.0.0",
|
||||
"@types/sinon": "^17.0.0",
|
||||
"chai": "^4.2.0",
|
||||
"@vitest/browser": "^2.1.4",
|
||||
"@vitest/coverage-istanbul": "^2.1.4",
|
||||
"dotenv": "^16.0.0",
|
||||
"eslint": "^9.9.0",
|
||||
"inherits": "^2.0.3",
|
||||
"karma": "^6.2.0",
|
||||
"karma-chrome-launcher": "^3.0.0",
|
||||
"karma-coverage": "^2.0.0",
|
||||
"karma-env-preprocessor": "^0.1.1",
|
||||
"karma-firefox-launcher": "^1.1.0",
|
||||
"karma-junit-reporter": "^2.0.1",
|
||||
"karma-mocha": "^2.0.1",
|
||||
"karma-mocha-reporter": "^2.2.5",
|
||||
"karma-sourcemap-loader": "^0.3.8",
|
||||
"mocha": "^10.0.0",
|
||||
"nyc": "^17.0.0",
|
||||
"sinon": "^17.0.0",
|
||||
"ts-node": "^10.0.0",
|
||||
"typescript": "~5.6.2"
|
||||
"playwright": "^1.48.2",
|
||||
"typescript": "~5.6.2",
|
||||
"vitest": "^2.1.4"
|
||||
},
|
||||
"//metadata": {
|
||||
"constantPaths": [
|
||||
|
@ -143,5 +127,43 @@
|
|||
"releasePhoneNumber.js",
|
||||
"manageSipRoutingConfiguration.js"
|
||||
]
|
||||
},
|
||||
"type": "module",
|
||||
"tshy": {
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": "./src/index.ts"
|
||||
},
|
||||
"dialects": [
|
||||
"esm",
|
||||
"commonjs"
|
||||
],
|
||||
"esmDialects": [
|
||||
"browser",
|
||||
"react-native"
|
||||
],
|
||||
"selfLink": false
|
||||
},
|
||||
"browser": "./dist/browser/index.js",
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"browser": {
|
||||
"types": "./dist/browser/index.d.ts",
|
||||
"default": "./dist/browser/index.js"
|
||||
},
|
||||
"react-native": {
|
||||
"types": "./dist/react-native/index.d.ts",
|
||||
"default": "./dist/react-native/index.js"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"default": "./dist/commonjs/index.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
/// <reference lib="esnext.asynciterable" />
|
||||
export { getContinuationToken } from "./pagingHelper";
|
||||
export * from "./models";
|
||||
export { PhoneNumbersClient } from "./phoneNumbersClient";
|
||||
export * from "./operationsInterfaces";
|
||||
export { getContinuationToken } from "./pagingHelper.js";
|
||||
export * from "./models/index.js";
|
||||
export { PhoneNumbersClient } from "./phoneNumbersClient.js";
|
||||
export * from "./operationsInterfaces/index.js";
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
PhoneNumberPurchaseRequest as PhoneNumberPurchaseRequestMapper,
|
||||
PhoneNumberCapabilitiesRequest as PhoneNumberCapabilitiesRequestMapper,
|
||||
OperatorInformationRequest as OperatorInformationRequestMapper,
|
||||
} from "../models/mappers";
|
||||
} from "../models/mappers.js";
|
||||
|
||||
export const accept: OperationParameter = {
|
||||
parameterPath: "accept",
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
export * from "./phoneNumbers";
|
||||
export * from "./phoneNumbers.js";
|
||||
|
|
|
@ -6,16 +6,16 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
import { tracingClient } from "../tracing";
|
||||
import { tracingClient } from "../tracing.js";
|
||||
import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
|
||||
import { setContinuationToken } from "../pagingHelper";
|
||||
import { PhoneNumbers } from "../operationsInterfaces";
|
||||
import { setContinuationToken } from "../pagingHelper.js";
|
||||
import { PhoneNumbers } from "../operationsInterfaces/index.js";
|
||||
import * as coreClient from "@azure/core-client";
|
||||
import * as Mappers from "../models/mappers";
|
||||
import * as Parameters from "../models/parameters";
|
||||
import { PhoneNumbersClient } from "../phoneNumbersClient";
|
||||
import * as Mappers from "../models/mappers.js";
|
||||
import * as Parameters from "../models/parameters.js";
|
||||
import { PhoneNumbersClient } from "../phoneNumbersClient.js";
|
||||
import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro";
|
||||
import { createLroSpec } from "../lroImpl";
|
||||
import { createLroSpec } from "../lroImpl.js";
|
||||
import {
|
||||
PhoneNumberAreaCode,
|
||||
PhoneNumbersListAreaCodesNextOptionalParams,
|
||||
|
@ -62,7 +62,7 @@ import {
|
|||
PhoneNumbersListAvailableLocalitiesNextResponse,
|
||||
PhoneNumbersListOfferingsNextResponse,
|
||||
PhoneNumbersListPhoneNumbersNextResponse,
|
||||
} from "../models";
|
||||
} from "../models/index.js";
|
||||
|
||||
/// <reference lib="esnext.asynciterable" />
|
||||
/** Class containing PhoneNumbers operations. */
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
export * from "./phoneNumbers";
|
||||
export * from "./phoneNumbers.js";
|
||||
|
|
|
@ -39,7 +39,7 @@ import {
|
|||
PhoneNumbersReleasePhoneNumberResponse,
|
||||
PhoneNumbersOperatorInformationSearchOptionalParams,
|
||||
PhoneNumbersOperatorInformationSearchResponse,
|
||||
} from "../models";
|
||||
} from "../models/index.js";
|
||||
|
||||
/// <reference lib="esnext.asynciterable" />
|
||||
/** Interface representing a PhoneNumbers. */
|
||||
|
|
|
@ -12,9 +12,9 @@ import {
|
|||
PipelineResponse,
|
||||
SendRequest,
|
||||
} from "@azure/core-rest-pipeline";
|
||||
import { PhoneNumbersImpl } from "./operations";
|
||||
import { PhoneNumbers } from "./operationsInterfaces";
|
||||
import { PhoneNumbersClientOptionalParams } from "./models";
|
||||
import { PhoneNumbersImpl } from "./operations/index.js";
|
||||
import { PhoneNumbers } from "./operationsInterfaces/index.js";
|
||||
import { PhoneNumbersClientOptionalParams } from "./models/index.js";
|
||||
|
||||
export class PhoneNumbersClient extends coreClient.ServiceClient {
|
||||
endpoint: string;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
export * from "./models";
|
||||
export { SipRoutingClient } from "./sipRoutingClient";
|
||||
export { SipRoutingClientContext } from "./sipRoutingClientContext";
|
||||
export * from "./operationsInterfaces";
|
||||
export * from "./models/index.js";
|
||||
export { SipRoutingClient } from "./sipRoutingClient.js";
|
||||
export { SipRoutingClientContext } from "./sipRoutingClientContext.js";
|
||||
export * from "./operationsInterfaces/index.js";
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
OperationURLParameter,
|
||||
OperationQueryParameter
|
||||
} from "@azure/core-client";
|
||||
import { SipConfigurationUpdate as SipConfigurationUpdateMapper } from "../models/mappers";
|
||||
import { SipConfigurationUpdate as SipConfigurationUpdateMapper } from "../models/mappers.js";
|
||||
|
||||
export const accept: OperationParameter = {
|
||||
parameterPath: "accept",
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
export * from "./sipRouting";
|
||||
export * from "./sipRouting.js";
|
||||
|
|
|
@ -6,17 +6,17 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
import { SipRouting } from "../operationsInterfaces";
|
||||
import { SipRouting } from "../operationsInterfaces/index.js";
|
||||
import * as coreClient from "@azure/core-client";
|
||||
import * as Mappers from "../models/mappers";
|
||||
import * as Parameters from "../models/parameters";
|
||||
import { SipRoutingClientContext } from "../sipRoutingClientContext";
|
||||
import * as Mappers from "../models/mappers.js";
|
||||
import * as Parameters from "../models/parameters.js";
|
||||
import { SipRoutingClientContext } from "../sipRoutingClientContext.js";
|
||||
import {
|
||||
SipRoutingGetOptionalParams,
|
||||
SipRoutingGetResponse,
|
||||
SipRoutingUpdateOptionalParams,
|
||||
SipRoutingUpdateResponse
|
||||
} from "../models";
|
||||
} from "../models/index.js";
|
||||
|
||||
/** Class containing SipRouting operations. */
|
||||
export class SipRoutingImpl implements SipRouting {
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
export * from "./sipRouting";
|
||||
export * from "./sipRouting.js";
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
SipRoutingGetResponse,
|
||||
SipRoutingUpdateOptionalParams,
|
||||
SipRoutingUpdateResponse
|
||||
} from "../models";
|
||||
} from "../models/index.js";
|
||||
|
||||
/** Interface representing a SipRouting. */
|
||||
export interface SipRouting {
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
import { SipRoutingImpl } from "./operations";
|
||||
import { SipRouting } from "./operationsInterfaces";
|
||||
import { SipRoutingClientContext } from "./sipRoutingClientContext";
|
||||
import { SipRoutingClientOptionalParams } from "./models";
|
||||
import { SipRoutingImpl } from "./operations/index.js";
|
||||
import { SipRouting } from "./operationsInterfaces/index.js";
|
||||
import { SipRoutingClientContext } from "./sipRoutingClientContext.js";
|
||||
import { SipRoutingClientOptionalParams } from "./models/index.js";
|
||||
|
||||
export class SipRoutingClient extends SipRoutingClientContext {
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import * as coreClient from "@azure/core-client";
|
||||
import { SipRoutingClientOptionalParams } from "./models";
|
||||
import { SipRoutingClientOptionalParams } from "./models/index.js";
|
||||
|
||||
export class SipRoutingClientContext extends coreClient.ServiceClient {
|
||||
endpoint: string;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
export * from "./models";
|
||||
export * from "./phoneNumbersClient";
|
||||
export * from "./lroModels";
|
||||
export * from "./sipRoutingClient";
|
||||
export * from "./models.js";
|
||||
export * from "./phoneNumbersClient.js";
|
||||
export * from "./lroModels.js";
|
||||
export * from "./sipRoutingClient.js";
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import type { SipTrunk } from "./models";
|
||||
import type { TrunkUpdate as RestSipTrunk } from "./generated/src/siprouting/models";
|
||||
import type { SipTrunk } from "./models.js";
|
||||
import type { TrunkUpdate as RestSipTrunk } from "./generated/src/siprouting/models/index.js";
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
|
|
@ -7,7 +7,7 @@ import type {
|
|||
PhoneNumberSearchRequest,
|
||||
PhoneNumbersListAreaCodesOptionalParams,
|
||||
PhoneNumberType,
|
||||
} from "./generated/src/models/";
|
||||
} from "./generated/src/models/index.js";
|
||||
|
||||
/**
|
||||
* The result of the phone numbers purchase operation.
|
||||
|
@ -113,9 +113,9 @@ export {
|
|||
OperatorInformationOptions,
|
||||
OperatorInformationResult,
|
||||
OperatorNumberType,
|
||||
} from "./generated/src/models/";
|
||||
} from "./generated/src/models/index.js";
|
||||
|
||||
export { SipRoutingError, SipTrunkRoute } from "./generated/src/siprouting/models";
|
||||
export { SipRoutingError, SipTrunkRoute } from "./generated/src/siprouting/models/index.js";
|
||||
|
||||
/**
|
||||
* Represents a SIP trunk for routing calls. See RFC 4904.
|
||||
|
|
|
@ -13,7 +13,7 @@ import { isTokenCredential } from "@azure/core-auth";
|
|||
import type { InternalPipelineOptions } from "@azure/core-rest-pipeline";
|
||||
import type { PollOperationState, PollerLike } from "@azure/core-lro";
|
||||
import type { PagedAsyncIterableIterator } from "@azure/core-paging";
|
||||
import { PhoneNumbersClient as PhoneNumbersGeneratedClient } from "./generated/src";
|
||||
import { PhoneNumbersClient as PhoneNumbersGeneratedClient } from "./generated/src/index.js";
|
||||
import type {
|
||||
OperatorInformationResult,
|
||||
PhoneNumberAreaCode,
|
||||
|
@ -23,7 +23,7 @@ import type {
|
|||
PhoneNumberOffering,
|
||||
PhoneNumberSearchResult,
|
||||
PurchasedPhoneNumber,
|
||||
} from "./generated/src/models/";
|
||||
} from "./generated/src/models/index.js";
|
||||
import type {
|
||||
GetPurchasedPhoneNumberOptions,
|
||||
ListAvailableCountriesOptions,
|
||||
|
@ -36,17 +36,17 @@ import type {
|
|||
ReleasePhoneNumberResult,
|
||||
SearchAvailablePhoneNumbersRequest,
|
||||
SearchOperatorInformationOptions,
|
||||
} from "./models";
|
||||
} from "./models.js";
|
||||
import type {
|
||||
BeginPurchasePhoneNumbersOptions,
|
||||
BeginReleasePhoneNumberOptions,
|
||||
BeginSearchAvailablePhoneNumbersOptions,
|
||||
BeginUpdatePhoneNumberCapabilitiesOptions,
|
||||
} from "./lroModels";
|
||||
import { createPhoneNumbersPagingPolicy } from "./utils/customPipelinePolicies";
|
||||
} from "./lroModels.js";
|
||||
import { createPhoneNumbersPagingPolicy } from "./utils/customPipelinePolicies.js";
|
||||
import type { CommonClientOptions } from "@azure/core-client";
|
||||
import { logger } from "./utils";
|
||||
import { tracingClient } from "./generated/src/tracing";
|
||||
import { logger } from "./utils/index.js";
|
||||
import { tracingClient } from "./generated/src/tracing.js";
|
||||
|
||||
/**
|
||||
* Client options used to configure the PhoneNumbersClient API requests.
|
||||
|
|
|
@ -10,16 +10,24 @@ import {
|
|||
import type { KeyCredential, TokenCredential } from "@azure/core-auth";
|
||||
import { isTokenCredential } from "@azure/core-auth";
|
||||
import type { InternalPipelineOptions } from "@azure/core-rest-pipeline";
|
||||
import { logger } from "./utils";
|
||||
import { SipRoutingClient as SipRoutingGeneratedClient } from "./generated/src/siprouting/sipRoutingClient";
|
||||
import type { SipConfigurationUpdate, SipRoutingError } from "./generated/src/siprouting/models";
|
||||
import type { ListSipRoutesOptions, ListSipTrunksOptions, SipTrunk, SipTrunkRoute } from "./models";
|
||||
import { transformFromRestModel, transformIntoRestModel } from "./mappers";
|
||||
import { logger } from "./utils/index.js";
|
||||
import { SipRoutingClient as SipRoutingGeneratedClient } from "./generated/src/siprouting/sipRoutingClient.js";
|
||||
import type {
|
||||
SipConfigurationUpdate,
|
||||
SipRoutingError,
|
||||
} from "./generated/src/siprouting/models/index.js";
|
||||
import type {
|
||||
ListSipRoutesOptions,
|
||||
ListSipTrunksOptions,
|
||||
SipTrunk,
|
||||
SipTrunkRoute,
|
||||
} from "./models.js";
|
||||
import { transformFromRestModel, transformIntoRestModel } from "./mappers.js";
|
||||
import type { CommonClientOptions, OperationOptions } from "@azure/core-client";
|
||||
import { tracingClient } from "./generated/src/tracing";
|
||||
import { tracingClient } from "./generated/src/tracing.js";
|
||||
import type { PagedAsyncIterableIterator } from "@azure/core-paging";
|
||||
|
||||
export * from "./models";
|
||||
export * from "./models.js";
|
||||
|
||||
/**
|
||||
* Client options used to configure the SipRoutingClient API requests.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
export * from "./constants";
|
||||
export * from "./logger";
|
||||
export * from "./constants.js";
|
||||
export * from "./logger.js";
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
import type { FullOperationResponse } from "@azure/core-client";
|
||||
import type { PipelineRequest, PipelineResponse } from "@azure/core-rest-pipeline";
|
||||
import { createHttpHeaders } from "@azure/core-rest-pipeline";
|
||||
import { assert } from "chai";
|
||||
import { createPhoneNumbersPagingPolicy } from "../../src/utils/customPipelinePolicies";
|
||||
import { createPhoneNumbersPagingPolicy } from "../../src/utils/customPipelinePolicies.js";
|
||||
import { describe, it, assert } from "vitest";
|
||||
|
||||
describe("phoneNumbersPagingPolicy", function () {
|
||||
const endpoint = "https://contoso.spool.azure.local";
|
||||
|
@ -18,7 +18,7 @@ describe("phoneNumbersPagingPolicy", function () {
|
|||
requestId: "any-id",
|
||||
};
|
||||
|
||||
async function createMockResponse(parsedBody: any) {
|
||||
async function createMockResponse(parsedBody: any): Promise<PipelineResponse> {
|
||||
return Promise.resolve({ parsedBody }) as unknown as PipelineResponse;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,18 +2,16 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
import { AzureKeyCredential } from "@azure/core-auth";
|
||||
import { isNode } from "@azure/core-util";
|
||||
import { isNodeLike } from "@azure/core-util";
|
||||
import type { TokenCredential } from "@azure/identity";
|
||||
import { assert } from "chai";
|
||||
import sinon from "sinon";
|
||||
import { PhoneNumbersClient } from "../../src/phoneNumbersClient";
|
||||
import { getPhoneNumberHttpClient } from "../public/utils/mockHttpClients";
|
||||
import { SDK_VERSION } from "../../src/utils/constants";
|
||||
import type { Context } from "mocha";
|
||||
import { createMockToken } from "../public/utils/recordedClient";
|
||||
import { PhoneNumbersClient } from "../../src/phoneNumbersClient.js";
|
||||
import { getPhoneNumberHttpClient } from "../public/utils/mockHttpClients.js";
|
||||
import { SDK_VERSION } from "../../src/utils/constants.js";
|
||||
import { createMockToken } from "../public/utils/recordedClient.js";
|
||||
import type { PipelineRequest } from "@azure/core-rest-pipeline";
|
||||
import { describe, it, assert, expect, vi } from "vitest";
|
||||
|
||||
describe("PhoneNumbersClient - headers", function () {
|
||||
describe("PhoneNumbersClient - headers", () => {
|
||||
const endpoint = "https://contoso.spool.azure.local";
|
||||
const accessKey = "banana";
|
||||
let client = new PhoneNumbersClient(endpoint, new AzureKeyCredential(accessKey), {
|
||||
|
@ -21,39 +19,32 @@ describe("PhoneNumbersClient - headers", function () {
|
|||
});
|
||||
let request: PipelineRequest;
|
||||
|
||||
afterEach(function () {
|
||||
sinon.restore();
|
||||
});
|
||||
|
||||
it("calls the spy", async function () {
|
||||
const spy = sinon.spy(getPhoneNumberHttpClient, "sendRequest");
|
||||
it("calls the spy", async () => {
|
||||
const spy = vi.spyOn(getPhoneNumberHttpClient, "sendRequest");
|
||||
await client.getPurchasedPhoneNumber("+18005550100");
|
||||
sinon.assert.calledOnce(spy);
|
||||
expect(spy).toHaveBeenCalledOnce();
|
||||
|
||||
request = spy.getCall(0).args[0];
|
||||
request = spy.mock.calls[0][0];
|
||||
});
|
||||
|
||||
it("[node] sets correct host", function (this: Context) {
|
||||
if (!isNode) {
|
||||
this.skip();
|
||||
}
|
||||
it.skipIf(!isNodeLike)("[node] sets correct host", () => {
|
||||
assert.equal(request.headers.get("host"), "contoso.spool.azure.local");
|
||||
});
|
||||
|
||||
it("sets correct default user-agent", function () {
|
||||
const userAgentHeader = isNode ? "user-agent" : "x-ms-useragent";
|
||||
it("sets correct default user-agent", () => {
|
||||
const userAgentHeader = isNodeLike ? "user-agent" : "x-ms-useragent";
|
||||
assert.match(
|
||||
request.headers.get(userAgentHeader) as string,
|
||||
new RegExp(`azsdk-js-communication-phone-numbers/${SDK_VERSION}`, "g"),
|
||||
);
|
||||
});
|
||||
|
||||
it("sets date header", function () {
|
||||
it("sets date header", () => {
|
||||
const dateHeader = "x-ms-date";
|
||||
assert.typeOf(request.headers.get(dateHeader), "string");
|
||||
});
|
||||
|
||||
it("sets signed authorization header with KeyCredential", function () {
|
||||
it("sets signed authorization header with KeyCredential", () => {
|
||||
assert.isDefined(request.headers.get("authorization"));
|
||||
assert.match(
|
||||
request.headers.get("authorization") as string,
|
||||
|
@ -61,16 +52,16 @@ describe("PhoneNumbersClient - headers", function () {
|
|||
);
|
||||
});
|
||||
|
||||
it("sets signed authorization header with connection string", async function () {
|
||||
it("sets signed authorization header with connection string", async () => {
|
||||
client = new PhoneNumbersClient(`endpoint=${endpoint};accessKey=${accessKey}`, {
|
||||
httpClient: getPhoneNumberHttpClient,
|
||||
});
|
||||
|
||||
const spy = sinon.spy(getPhoneNumberHttpClient, "sendRequest");
|
||||
const spy = vi.spyOn(getPhoneNumberHttpClient, "sendRequest");
|
||||
await client.getPurchasedPhoneNumber("+18005550100");
|
||||
sinon.assert.calledOnce(spy);
|
||||
expect(spy).toHaveBeenCalledOnce();
|
||||
|
||||
request = spy.getCall(0).args[0];
|
||||
request = spy.mock.calls[0][0];
|
||||
assert.isDefined(request.headers.get("authorization"));
|
||||
assert.match(
|
||||
request.headers.get("authorization") as string,
|
||||
|
@ -78,23 +69,23 @@ describe("PhoneNumbersClient - headers", function () {
|
|||
);
|
||||
});
|
||||
|
||||
it("sets bearer authorization header with TokenCredential", async function (this: Context) {
|
||||
it("sets bearer authorization header with TokenCredential", async () => {
|
||||
const credential: TokenCredential = createMockToken();
|
||||
|
||||
client = new PhoneNumbersClient(endpoint, credential, {
|
||||
httpClient: getPhoneNumberHttpClient,
|
||||
});
|
||||
|
||||
const spy = sinon.spy(getPhoneNumberHttpClient, "sendRequest");
|
||||
const spy = vi.spyOn(getPhoneNumberHttpClient, "sendRequest");
|
||||
await client.getPurchasedPhoneNumber("+18005550100");
|
||||
sinon.assert.calledOnce(spy);
|
||||
expect(spy).toHaveBeenCalledOnce();
|
||||
|
||||
request = spy.getCall(0).args[0];
|
||||
request = spy.mock.calls[0][0];
|
||||
assert.isDefined(request.headers.get("authorization"));
|
||||
assert.match(request.headers.get("authorization") as string, /Bearer ./);
|
||||
});
|
||||
|
||||
it("can set custom user-agent prefix", async function () {
|
||||
it("can set custom user-agent prefix", async () => {
|
||||
client = new PhoneNumbersClient(`endpoint=${endpoint};accessKey=${accessKey}`, {
|
||||
httpClient: getPhoneNumberHttpClient,
|
||||
userAgentOptions: {
|
||||
|
@ -102,13 +93,13 @@ describe("PhoneNumbersClient - headers", function () {
|
|||
},
|
||||
});
|
||||
|
||||
const spy = sinon.spy(getPhoneNumberHttpClient, "sendRequest");
|
||||
const spy = vi.spyOn(getPhoneNumberHttpClient, "sendRequest");
|
||||
await client.getPurchasedPhoneNumber("+18005550100");
|
||||
sinon.assert.calledOnce(spy);
|
||||
expect(spy).toHaveBeenCalledOnce();
|
||||
|
||||
request = spy.getCall(0).args[0];
|
||||
request = spy.mock.calls[0][0];
|
||||
|
||||
const userAgentHeader = isNode ? "user-agent" : "x-ms-useragent";
|
||||
const userAgentHeader = isNodeLike ? "user-agent" : "x-ms-useragent";
|
||||
assert.match(
|
||||
request.headers.get(userAgentHeader) as string,
|
||||
new RegExp(
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
import { AzureKeyCredential } from "@azure/core-auth";
|
||||
import { assert } from "chai";
|
||||
import { PhoneNumbersClient } from "../../src/phoneNumbersClient";
|
||||
import { mockListPhoneNumbersHttpClient } from "../public/utils/mockHttpClients";
|
||||
import { PhoneNumbersClient } from "../../src/phoneNumbersClient.js";
|
||||
import { mockListPhoneNumbersHttpClient } from "../public/utils/mockHttpClients.js";
|
||||
import { describe, it, assert } from "vitest";
|
||||
|
||||
describe("PhoneNumbersClient - custom policies ", function () {
|
||||
describe("PhoneNumbersClient - custom policies ", () => {
|
||||
const endpoint = "https://contoso.spool.azure.local";
|
||||
const accessKey = "banana";
|
||||
let client: PhoneNumbersClient;
|
||||
|
||||
it("applies the phoneNumbersPagingPolicy", async function () {
|
||||
it("applies the phoneNumbersPagingPolicy", async () => {
|
||||
client = new PhoneNumbersClient(endpoint, new AzureKeyCredential(accessKey), {
|
||||
httpClient: mockListPhoneNumbersHttpClient,
|
||||
});
|
||||
|
|
|
@ -2,18 +2,16 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
import { AzureKeyCredential } from "@azure/core-auth";
|
||||
import { isNode } from "@azure/core-util";
|
||||
import { isNodeLike } from "@azure/core-util";
|
||||
import type { TokenCredential } from "@azure/identity";
|
||||
import { assert } from "chai";
|
||||
import sinon from "sinon";
|
||||
import { SipRoutingClient } from "../../../src/sipRoutingClient";
|
||||
import { getTrunksHttpClient } from "../../public/siprouting/utils/mockHttpClients";
|
||||
import { SDK_VERSION } from "../../../src/utils/constants";
|
||||
import type { Context } from "mocha";
|
||||
import { createMockToken } from "../../public/utils/recordedClient";
|
||||
import { SipRoutingClient } from "../../../src/sipRoutingClient.js";
|
||||
import { getTrunksHttpClient } from "../../public/siprouting/utils/mockHttpClients.js";
|
||||
import { SDK_VERSION } from "../../../src/utils/constants.js";
|
||||
import { createMockToken } from "../../public/utils/recordedClient.js";
|
||||
import type { PipelineRequest } from "@azure/core-rest-pipeline";
|
||||
import { describe, it, assert, expect, vi } from "vitest";
|
||||
|
||||
describe("SipRoutingClient - headers", function () {
|
||||
describe("SipRoutingClient - headers", () => {
|
||||
const endpoint = "https://contoso.spool.azure.local";
|
||||
const accessKey = "banana";
|
||||
let client = new SipRoutingClient(endpoint, new AzureKeyCredential(accessKey), {
|
||||
|
@ -21,40 +19,33 @@ describe("SipRoutingClient - headers", function () {
|
|||
});
|
||||
let request: PipelineRequest;
|
||||
|
||||
afterEach(function () {
|
||||
sinon.restore();
|
||||
});
|
||||
|
||||
it("calls the spy", async function () {
|
||||
const spy = sinon.spy(getTrunksHttpClient, "sendRequest");
|
||||
const iter = await client.listTrunks();
|
||||
it("calls the spy", async () => {
|
||||
const spy = vi.spyOn(getTrunksHttpClient, "sendRequest");
|
||||
const iter = client.listTrunks();
|
||||
await iter.next();
|
||||
sinon.assert.calledOnce(spy);
|
||||
expect(spy).toHaveBeenCalledOnce();
|
||||
|
||||
request = spy.getCall(0).args[0];
|
||||
request = spy.mock.calls[0][0];
|
||||
});
|
||||
|
||||
it("[node] sets correct host", function (this: Context) {
|
||||
if (!isNode) {
|
||||
this.skip();
|
||||
}
|
||||
it.skipIf(!isNodeLike)("[node] sets correct host", () => {
|
||||
assert.equal(request.headers.get("host"), "contoso.spool.azure.local");
|
||||
});
|
||||
|
||||
it("sets correct default user-agent", function () {
|
||||
const userAgentHeader = isNode ? "user-agent" : "x-ms-useragent";
|
||||
it("sets correct default user-agent", () => {
|
||||
const userAgentHeader = isNodeLike ? "user-agent" : "x-ms-useragent";
|
||||
assert.match(
|
||||
request.headers.get(userAgentHeader) as string,
|
||||
new RegExp(`azsdk-js-communication-phone-numbers/${SDK_VERSION}`, "g"),
|
||||
);
|
||||
});
|
||||
|
||||
it("sets date header", function () {
|
||||
it("sets date header", () => {
|
||||
const dateHeader = "x-ms-date";
|
||||
assert.typeOf(request.headers.get(dateHeader), "string");
|
||||
});
|
||||
|
||||
it("sets signed authorization header with KeyCredential", function () {
|
||||
it("sets signed authorization header with KeyCredential", () => {
|
||||
assert.isDefined(request.headers.get("authorization"));
|
||||
assert.match(
|
||||
request.headers.get("authorization") as string,
|
||||
|
@ -62,17 +53,17 @@ describe("SipRoutingClient - headers", function () {
|
|||
);
|
||||
});
|
||||
|
||||
it("sets signed authorization header with connection string", async function () {
|
||||
it("sets signed authorization header with connection string", async () => {
|
||||
client = new SipRoutingClient(`endpoint=${endpoint};accessKey=${accessKey}`, {
|
||||
httpClient: getTrunksHttpClient,
|
||||
});
|
||||
|
||||
const spy = sinon.spy(getTrunksHttpClient, "sendRequest");
|
||||
const iter = await client.listTrunks();
|
||||
const spy = vi.spyOn(getTrunksHttpClient, "sendRequest");
|
||||
const iter = client.listTrunks();
|
||||
await iter.next();
|
||||
sinon.assert.calledOnce(spy);
|
||||
expect(spy).toHaveBeenCalledOnce();
|
||||
|
||||
request = spy.getCall(0).args[0];
|
||||
request = spy.mock.calls[0][0];
|
||||
assert.isDefined(request.headers.get("authorization"));
|
||||
assert.match(
|
||||
request.headers.get("authorization") as string,
|
||||
|
@ -80,24 +71,24 @@ describe("SipRoutingClient - headers", function () {
|
|||
);
|
||||
});
|
||||
|
||||
it("sets bearer authorization header with TokenCredential", async function (this: Context) {
|
||||
it("sets bearer authorization header with TokenCredential", async () => {
|
||||
const credential: TokenCredential = createMockToken();
|
||||
|
||||
client = new SipRoutingClient(endpoint, credential, {
|
||||
httpClient: getTrunksHttpClient,
|
||||
});
|
||||
|
||||
const spy = sinon.spy(getTrunksHttpClient, "sendRequest");
|
||||
const iter = await client.listTrunks();
|
||||
const spy = vi.spyOn(getTrunksHttpClient, "sendRequest");
|
||||
const iter = client.listTrunks();
|
||||
await iter.next();
|
||||
sinon.assert.calledOnce(spy);
|
||||
expect(spy).toHaveBeenCalledOnce();
|
||||
|
||||
request = spy.getCall(0).args[0];
|
||||
request = spy.mock.calls[0][0];
|
||||
assert.isDefined(request.headers.get("authorization"));
|
||||
assert.match(request.headers.get("authorization") as string, /Bearer ./);
|
||||
});
|
||||
|
||||
it("can set custom user-agent prefix", async function () {
|
||||
it("can set custom user-agent prefix", async () => {
|
||||
client = new SipRoutingClient(`endpoint=${endpoint};accessKey=${accessKey}`, {
|
||||
httpClient: getTrunksHttpClient,
|
||||
userAgentOptions: {
|
||||
|
@ -105,14 +96,14 @@ describe("SipRoutingClient - headers", function () {
|
|||
},
|
||||
});
|
||||
|
||||
const spy = sinon.spy(getTrunksHttpClient, "sendRequest");
|
||||
const iter = await client.listTrunks();
|
||||
const spy = vi.spyOn(getTrunksHttpClient, "sendRequest");
|
||||
const iter = client.listTrunks();
|
||||
await iter.next();
|
||||
sinon.assert.calledOnce(spy);
|
||||
expect(spy).toHaveBeenCalledOnce();
|
||||
|
||||
request = spy.getCall(0).args[0];
|
||||
request = spy.mock.calls[0][0];
|
||||
|
||||
const userAgentHeader = isNode ? "user-agent" : "x-ms-useragent";
|
||||
const userAgentHeader = isNodeLike ? "user-agent" : "x-ms-useragent";
|
||||
assert.match(
|
||||
request.headers.get(userAgentHeader) as string,
|
||||
new RegExp(
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import { matrix } from "@azure-tools/test-utils";
|
||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import { assert } from "chai";
|
||||
import type { Context } from "mocha";
|
||||
import type { PhoneNumbersListAreaCodesOptionalParams, PhoneNumbersClient } from "../../src";
|
||||
import { createRecordedClient, createRecordedClientWithToken } from "./utils/recordedClient";
|
||||
import type {
|
||||
PhoneNumbersListAreaCodesOptionalParams,
|
||||
PhoneNumbersClient,
|
||||
} from "../../src/index.js";
|
||||
import { createRecordedClient, createRecordedClientWithToken } from "./utils/recordedClient.js";
|
||||
import { describe, it, assert, beforeEach, afterEach } from "vitest";
|
||||
|
||||
matrix([[true, false]], async function (useAad) {
|
||||
describe(`PhoneNumbersClient - area codes lists${useAad ? " [AAD]" : ""}`, function () {
|
||||
matrix([[true, false]], async (useAad) => {
|
||||
describe(`PhoneNumbersClient - area codes lists${useAad ? " [AAD]" : ""}`, () => {
|
||||
let recorder: Recorder;
|
||||
let client: PhoneNumbersClient;
|
||||
|
||||
beforeEach(async function (this: Context) {
|
||||
beforeEach(async (ctx) => {
|
||||
({ client, recorder } = useAad
|
||||
? await createRecordedClientWithToken(this)!
|
||||
: await createRecordedClient(this));
|
||||
? await createRecordedClientWithToken(ctx)!
|
||||
: await createRecordedClient(ctx));
|
||||
});
|
||||
|
||||
afterEach(async function (this: Context) {
|
||||
if (!this.currentTest?.isPending()) {
|
||||
await recorder.stop();
|
||||
}
|
||||
afterEach(async () => {
|
||||
await recorder.stop();
|
||||
});
|
||||
|
||||
it("can list all geographic area codes", async function () {
|
||||
it("can list all geographic area codes", { timeout: 60000 }, async () => {
|
||||
const availableLocalities = await client.listAvailableLocalities("US");
|
||||
const locality = await availableLocalities.next();
|
||||
const request: PhoneNumbersListAreaCodesOptionalParams = {
|
||||
|
@ -36,9 +36,9 @@ matrix([[true, false]], async function (useAad) {
|
|||
for await (const areaCode of areaCodes) {
|
||||
assert.isNotNull(areaCode);
|
||||
}
|
||||
}).timeout(60000);
|
||||
});
|
||||
|
||||
it("can list all toll free area codes", async function () {
|
||||
it("can list all toll free area codes", { timeout: 60000 }, async () => {
|
||||
const tollFreeAreaCodesList = [
|
||||
{
|
||||
areaCode: "888",
|
||||
|
@ -69,6 +69,6 @@ matrix([[true, false]], async function (useAad) {
|
|||
for await (const areaCode of areaCodes) {
|
||||
assert.deepInclude(tollFreeAreaCodesList, areaCode);
|
||||
}
|
||||
}).timeout(60000);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,31 +2,28 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
import { setLogLevel } from "@azure/logger";
|
||||
import { matrix } from "@azure-tools/test-utils";
|
||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import { assert } from "chai";
|
||||
import type { Context } from "mocha";
|
||||
import type { PhoneNumbersClient } from "../../src";
|
||||
import { createRecordedClient, createRecordedClientWithToken } from "./utils/recordedClient";
|
||||
import type { PhoneNumbersClient } from "../../src/index.js";
|
||||
import { createRecordedClient, createRecordedClientWithToken } from "./utils/recordedClient.js";
|
||||
import { describe, it, assert, beforeEach, afterEach } from "vitest";
|
||||
|
||||
matrix([[true, false]], async function (useAad) {
|
||||
describe(`PhoneNumbersClient - countries lists${useAad ? " [AAD]" : ""}`, function () {
|
||||
matrix([[true, false]], async (useAad) => {
|
||||
describe(`PhoneNumbersClient - countries lists${useAad ? " [AAD]" : ""}`, () => {
|
||||
let recorder: Recorder;
|
||||
let client: PhoneNumbersClient;
|
||||
|
||||
beforeEach(async function (this: Context) {
|
||||
beforeEach(async (ctx) => {
|
||||
({ client, recorder } = useAad
|
||||
? await createRecordedClientWithToken(this)!
|
||||
: await createRecordedClient(this));
|
||||
? await createRecordedClientWithToken(ctx)!
|
||||
: await createRecordedClient(ctx));
|
||||
});
|
||||
|
||||
afterEach(async function (this: Context) {
|
||||
if (!this.currentTest?.isPending()) {
|
||||
await recorder.stop();
|
||||
}
|
||||
afterEach(async () => {
|
||||
await recorder.stop();
|
||||
});
|
||||
|
||||
it("can list all available countries", async function () {
|
||||
it("can list all available countries", { timeout: 60000 }, async () => {
|
||||
const countriesList = [
|
||||
{
|
||||
localizedName: "Canada",
|
||||
|
@ -45,6 +42,6 @@ matrix([[true, false]], async function (useAad) {
|
|||
assert.deepInclude(responseCountries, currentCountry);
|
||||
}
|
||||
setLogLevel("error");
|
||||
}).timeout(60000);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,32 +2,31 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
import { AzureKeyCredential } from "@azure/core-auth";
|
||||
import { assert } from "chai";
|
||||
import type { Context } from "mocha";
|
||||
import { PhoneNumbersClient } from "../../src";
|
||||
import { createMockToken } from "./utils/recordedClient";
|
||||
import { PhoneNumbersClient } from "../../src/index.js";
|
||||
import { createMockToken } from "./utils/recordedClient.js";
|
||||
import { describe, it, assert } from "vitest";
|
||||
|
||||
describe("PhoneNumbersClient - constructor", function () {
|
||||
describe("PhoneNumbersClient - constructor", () => {
|
||||
const endpoint = "https://contoso.spool.azure.local";
|
||||
const accessKey = "banana";
|
||||
|
||||
it("successfully instantiates with valid connection string", function () {
|
||||
it("successfully instantiates with valid connection string", () => {
|
||||
const client = new PhoneNumbersClient(`endpoint=${endpoint};accesskey=${accessKey}`);
|
||||
assert.instanceOf(client, PhoneNumbersClient);
|
||||
});
|
||||
|
||||
it("throws with invalid connection string", function () {
|
||||
it("throws with invalid connection string", () => {
|
||||
assert.throws(() => {
|
||||
new PhoneNumbersClient(`endpoints=${endpoint};accesskey=${accessKey}`);
|
||||
});
|
||||
});
|
||||
|
||||
it("successfully instantiates with with endpoint and access key", function () {
|
||||
it("successfully instantiates with with endpoint and access key", () => {
|
||||
const client = new PhoneNumbersClient(endpoint, new AzureKeyCredential(accessKey));
|
||||
assert.instanceOf(client, PhoneNumbersClient);
|
||||
});
|
||||
|
||||
it("successfully instantiates with with endpoint and managed identity", function (this: Context) {
|
||||
it("successfully instantiates with with endpoint and managed identity", () => {
|
||||
const client = new PhoneNumbersClient(endpoint, createMockToken());
|
||||
assert.instanceOf(client, PhoneNumbersClient);
|
||||
});
|
||||
|
|
|
@ -1,39 +1,36 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import { matrix } from "@azure-tools/test-utils";
|
||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import { assert } from "chai";
|
||||
import type { Context } from "mocha";
|
||||
import type { PhoneNumbersClient } from "../../src";
|
||||
import { createRecordedClient, createRecordedClientWithToken } from "./utils/recordedClient";
|
||||
import { getPhoneNumber } from "./utils/testPhoneNumber";
|
||||
import type { PhoneNumbersClient } from "../../src/index.js";
|
||||
import { createRecordedClient, createRecordedClientWithToken } from "./utils/recordedClient.js";
|
||||
import { getPhoneNumber } from "./utils/testPhoneNumber.js";
|
||||
import { describe, it, assert, beforeEach, afterEach } from "vitest";
|
||||
|
||||
matrix([[true, false]], async function (useAad) {
|
||||
describe(`PhoneNumbersClient - get phone number${useAad ? " [AAD]" : ""}`, function () {
|
||||
matrix([[true, false]], async (useAad) => {
|
||||
describe(`PhoneNumbersClient - get phone number${useAad ? " [AAD]" : ""}`, () => {
|
||||
let recorder: Recorder;
|
||||
let client: PhoneNumbersClient;
|
||||
|
||||
beforeEach(async function (this: Context) {
|
||||
beforeEach(async (ctx) => {
|
||||
({ client, recorder } = useAad
|
||||
? await createRecordedClientWithToken(this)!
|
||||
: await createRecordedClient(this));
|
||||
? await createRecordedClientWithToken(ctx)!
|
||||
: await createRecordedClient(ctx));
|
||||
});
|
||||
|
||||
afterEach(async function (this: Context) {
|
||||
if (!this.currentTest?.isPending()) {
|
||||
await recorder.stop();
|
||||
}
|
||||
afterEach(async () => {
|
||||
await recorder.stop();
|
||||
});
|
||||
|
||||
it("can get a purchased phone number", async function (this: Context) {
|
||||
it("can get a purchased phone number", { timeout: 60000 }, async () => {
|
||||
const purchasedPhoneNumber = getPhoneNumber();
|
||||
const { phoneNumber } = await client.getPurchasedPhoneNumber(purchasedPhoneNumber);
|
||||
|
||||
assert.strictEqual(purchasedPhoneNumber, phoneNumber);
|
||||
}).timeout(60000);
|
||||
});
|
||||
|
||||
it("errors if phone number not found", async function () {
|
||||
it("errors if phone number not found", async () => {
|
||||
const fake = "+14155550100";
|
||||
try {
|
||||
await client.getPurchasedPhoneNumber(fake);
|
||||
|
|
|
@ -1,31 +1,28 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import { matrix } from "@azure-tools/test-utils";
|
||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import { assert } from "chai";
|
||||
import type { Context } from "mocha";
|
||||
import type { PhoneNumbersClient } from "../../src";
|
||||
import { createRecordedClient, createRecordedClientWithToken } from "./utils/recordedClient";
|
||||
import type { PhoneNumbersClient } from "../../src/index.js";
|
||||
import { createRecordedClient, createRecordedClientWithToken } from "./utils/recordedClient.js";
|
||||
import { describe, it, assert, beforeEach, afterEach } from "vitest";
|
||||
|
||||
matrix([[true, false]], async function (useAad) {
|
||||
describe(`PhoneNumbersClient - lists${useAad ? " [AAD]" : ""}`, function () {
|
||||
matrix([[true, false]], async (useAad) => {
|
||||
describe(`PhoneNumbersClient - lists${useAad ? " [AAD]" : ""}`, () => {
|
||||
let recorder: Recorder;
|
||||
let client: PhoneNumbersClient;
|
||||
|
||||
beforeEach(async function (this: Context) {
|
||||
beforeEach(async (ctx) => {
|
||||
({ client, recorder } = useAad
|
||||
? await createRecordedClientWithToken(this)!
|
||||
: await createRecordedClient(this));
|
||||
? await createRecordedClientWithToken(ctx)!
|
||||
: await createRecordedClient(ctx));
|
||||
});
|
||||
|
||||
afterEach(async function (this: Context) {
|
||||
if (!this.currentTest?.isPending()) {
|
||||
await recorder.stop();
|
||||
}
|
||||
afterEach(async () => {
|
||||
await recorder.stop();
|
||||
});
|
||||
|
||||
it("can list all purchased phone numbers", async function () {
|
||||
it("can list all purchased phone numbers", { timeout: 60000 }, async () => {
|
||||
let all = 0;
|
||||
for await (const purchased of client.listPurchasedPhoneNumbers()) {
|
||||
assert.match(purchased.phoneNumber, /\+\d{1}\d{3}\d{3}\d{4}/g);
|
||||
|
@ -33,6 +30,6 @@ matrix([[true, false]], async function (useAad) {
|
|||
}
|
||||
|
||||
assert.isTrue(all > 0);
|
||||
}).timeout(60000);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,51 +1,52 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import { matrix } from "@azure-tools/test-utils";
|
||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import { assert } from "chai";
|
||||
import type { Context } from "mocha";
|
||||
import type { ListLocalitiesOptions, PhoneNumbersClient } from "../../src";
|
||||
import { createRecordedClient, createRecordedClientWithToken } from "./utils/recordedClient";
|
||||
import type { ListLocalitiesOptions, PhoneNumbersClient } from "../../src/index.js";
|
||||
import { createRecordedClient, createRecordedClientWithToken } from "./utils/recordedClient.js";
|
||||
import { describe, it, assert, beforeEach, afterEach } from "vitest";
|
||||
|
||||
matrix([[true, false]], async function (useAad) {
|
||||
describe(`PhoneNumbersClient - localities lists${useAad ? " [AAD]" : ""}`, function () {
|
||||
matrix([[true, false]], async (useAad) => {
|
||||
describe(`PhoneNumbersClient - localities lists${useAad ? " [AAD]" : ""}`, () => {
|
||||
let recorder: Recorder;
|
||||
let client: PhoneNumbersClient;
|
||||
|
||||
beforeEach(async function (this: Context) {
|
||||
beforeEach(async (ctx) => {
|
||||
({ client, recorder } = useAad
|
||||
? await createRecordedClientWithToken(this)!
|
||||
: await createRecordedClient(this));
|
||||
? await createRecordedClientWithToken(ctx)!
|
||||
: await createRecordedClient(ctx));
|
||||
});
|
||||
|
||||
afterEach(async function (this: Context) {
|
||||
if (!this.currentTest?.isPending()) {
|
||||
await recorder.stop();
|
||||
}
|
||||
afterEach(async () => {
|
||||
await recorder.stop();
|
||||
});
|
||||
|
||||
it("can list available localities", async function () {
|
||||
it("can list available localities", { timeout: 60000 }, async () => {
|
||||
const responseLocalities = [];
|
||||
for await (const locality of client.listAvailableLocalities("US")) {
|
||||
responseLocalities.push(locality);
|
||||
}
|
||||
assert.isNotEmpty(responseLocalities);
|
||||
}).timeout(60000);
|
||||
});
|
||||
|
||||
it("can list available localities with administrative division", async function () {
|
||||
const availableLocalities = await client.listAvailableLocalities("US");
|
||||
const firstLocality = await availableLocalities.next();
|
||||
const request: ListLocalitiesOptions = {
|
||||
administrativeDivision: firstLocality.value.administrativeDivision.abbreviatedName,
|
||||
};
|
||||
it(
|
||||
"can list available localities with administrative division",
|
||||
{ timeout: 60000 },
|
||||
async () => {
|
||||
const availableLocalities = await client.listAvailableLocalities("US");
|
||||
const firstLocality = await availableLocalities.next();
|
||||
const request: ListLocalitiesOptions = {
|
||||
administrativeDivision: firstLocality.value.administrativeDivision.abbreviatedName,
|
||||
};
|
||||
|
||||
for await (const locality of client.listAvailableLocalities("US", request)) {
|
||||
assert.equal(
|
||||
locality.administrativeDivision?.abbreviatedName,
|
||||
firstLocality.value.administrativeDivision.abbreviatedName,
|
||||
);
|
||||
}
|
||||
}).timeout(60000);
|
||||
for await (const locality of client.listAvailableLocalities("US", request)) {
|
||||
assert.equal(
|
||||
locality.administrativeDivision?.abbreviatedName,
|
||||
firstLocality.value.administrativeDivision.abbreviatedName,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,83 +1,79 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import { matrix } from "@azure-tools/test-utils";
|
||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import { env, isPlaybackMode } from "@azure-tools/test-recorder";
|
||||
import { assert } from "chai";
|
||||
import type { Context } from "mocha";
|
||||
import type { PhoneNumbersClient, SearchAvailablePhoneNumbersRequest } from "../../src";
|
||||
import { createRecordedClient, createRecordedClientWithToken } from "./utils/recordedClient";
|
||||
import type { PhoneNumbersClient, SearchAvailablePhoneNumbersRequest } from "../../src/index.js";
|
||||
import { createRecordedClient, createRecordedClientWithToken } from "./utils/recordedClient.js";
|
||||
import { describe, it, assert, beforeEach, afterEach } from "vitest";
|
||||
|
||||
matrix([[true, false]], async function (useAad) {
|
||||
describe(`PhoneNumbersClient - lro - purchase and release${useAad ? " [AAD]" : ""}`, function () {
|
||||
let recorder: Recorder;
|
||||
let client: PhoneNumbersClient;
|
||||
matrix([[true, false]], async (useAad) => {
|
||||
const includePhoneNumberLiveTests = env.INCLUDE_PHONENUMBER_LIVE_TESTS === "true";
|
||||
|
||||
before(function (this: Context) {
|
||||
const includePhoneNumberLiveTests = env.INCLUDE_PHONENUMBER_LIVE_TESTS === "true";
|
||||
if (!includePhoneNumberLiveTests && !isPlaybackMode()) {
|
||||
this.skip();
|
||||
}
|
||||
});
|
||||
describe(
|
||||
`PhoneNumbersClient - lro - purchase and release${useAad ? " [AAD]" : ""}`,
|
||||
{ skip: !includePhoneNumberLiveTests && !isPlaybackMode() },
|
||||
() => {
|
||||
let recorder: Recorder;
|
||||
let client: PhoneNumbersClient;
|
||||
|
||||
beforeEach(async function (this: Context) {
|
||||
({ client, recorder } = useAad
|
||||
? await createRecordedClientWithToken(this)!
|
||||
: await createRecordedClient(this));
|
||||
});
|
||||
beforeEach(async (ctx) => {
|
||||
({ client, recorder } = useAad
|
||||
? await createRecordedClientWithToken(ctx)!
|
||||
: await createRecordedClient(ctx));
|
||||
});
|
||||
|
||||
afterEach(async function (this: Context) {
|
||||
if (!this.currentTest?.isPending()) {
|
||||
afterEach(async () => {
|
||||
await recorder.stop();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("can purchase and release a phone number", async function (this: Context) {
|
||||
// search for phone number
|
||||
const searchRequest: SearchAvailablePhoneNumbersRequest = {
|
||||
countryCode: "US",
|
||||
phoneNumberType: "tollFree",
|
||||
assignmentType: "application",
|
||||
capabilities: {
|
||||
sms: "inbound+outbound",
|
||||
calling: "none",
|
||||
},
|
||||
};
|
||||
const searchPoller = await client.beginSearchAvailablePhoneNumbers(searchRequest);
|
||||
const searchResults = await searchPoller.pollUntilDone();
|
||||
it("can purchase and release a phone number", { timeout: 90000 }, async () => {
|
||||
// search for phone number
|
||||
const searchRequest: SearchAvailablePhoneNumbersRequest = {
|
||||
countryCode: "US",
|
||||
phoneNumberType: "tollFree",
|
||||
assignmentType: "application",
|
||||
capabilities: {
|
||||
sms: "inbound+outbound",
|
||||
calling: "none",
|
||||
},
|
||||
};
|
||||
const searchPoller = await client.beginSearchAvailablePhoneNumbers(searchRequest);
|
||||
const searchResults = await searchPoller.pollUntilDone();
|
||||
|
||||
assert.ok(searchPoller.getOperationState().isCompleted);
|
||||
assert.isNotEmpty(searchResults.searchId);
|
||||
assert.isNotEmpty(searchResults.phoneNumbers);
|
||||
assert.equal(searchResults.phoneNumbers.length, 1);
|
||||
assert.ok(searchPoller.getOperationState().isCompleted);
|
||||
assert.isNotEmpty(searchResults.searchId);
|
||||
assert.isNotEmpty(searchResults.phoneNumbers);
|
||||
assert.equal(searchResults.phoneNumbers.length, 1);
|
||||
|
||||
const purchasedPhoneNumber = searchResults.phoneNumbers[0];
|
||||
assert.isNotEmpty(purchasedPhoneNumber);
|
||||
const purchasedPhoneNumber = searchResults.phoneNumbers[0];
|
||||
assert.isNotEmpty(purchasedPhoneNumber);
|
||||
|
||||
// purchase phone number
|
||||
const purchasePoller = await client.beginPurchasePhoneNumbers(searchResults.searchId);
|
||||
// purchase phone number
|
||||
const purchasePoller = await client.beginPurchasePhoneNumbers(searchResults.searchId);
|
||||
|
||||
await purchasePoller.pollUntilDone();
|
||||
assert.ok(purchasePoller.getOperationState().isCompleted);
|
||||
await purchasePoller.pollUntilDone();
|
||||
assert.ok(purchasePoller.getOperationState().isCompleted);
|
||||
|
||||
console.log(`Purchased ${purchasedPhoneNumber}`);
|
||||
console.log(`Purchased ${purchasedPhoneNumber}`);
|
||||
|
||||
// get phone number to ensure it was purchased
|
||||
const { phoneNumber } = await client.getPurchasedPhoneNumber(purchasedPhoneNumber);
|
||||
assert.equal(purchasedPhoneNumber, phoneNumber);
|
||||
// get phone number to ensure it was purchased
|
||||
const { phoneNumber } = await client.getPurchasedPhoneNumber(purchasedPhoneNumber);
|
||||
assert.equal(purchasedPhoneNumber, phoneNumber);
|
||||
|
||||
// release phone number
|
||||
console.log(`Will release ${purchasedPhoneNumber}`);
|
||||
// release phone number
|
||||
console.log(`Will release ${purchasedPhoneNumber}`);
|
||||
|
||||
const releasePoller = await client.beginReleasePhoneNumber(purchasedPhoneNumber as string);
|
||||
const releasePoller = await client.beginReleasePhoneNumber(purchasedPhoneNumber as string);
|
||||
|
||||
await releasePoller.pollUntilDone();
|
||||
assert.ok(releasePoller.getOperationState().isCompleted);
|
||||
const result = releasePoller.getOperationState().result! as any;
|
||||
assert.equal(result.body.status, "succeeded");
|
||||
await releasePoller.pollUntilDone();
|
||||
assert.ok(releasePoller.getOperationState().isCompleted);
|
||||
const result = releasePoller.getOperationState().result! as any;
|
||||
assert.equal(result.body.status, "succeeded");
|
||||
|
||||
console.log(`Released: ${purchasedPhoneNumber}`);
|
||||
}).timeout(90000);
|
||||
});
|
||||
console.log(`Released: ${purchasedPhoneNumber}`);
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,80 +1,76 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import { matrix } from "@azure-tools/test-utils";
|
||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import { env, isPlaybackMode } from "@azure-tools/test-recorder";
|
||||
import { assert } from "chai";
|
||||
import type { Context } from "mocha";
|
||||
import type { PhoneNumbersClient, SearchAvailablePhoneNumbersRequest } from "../../src";
|
||||
import { createRecordedClient, createRecordedClientWithToken } from "./utils/recordedClient";
|
||||
import { isClientErrorStatusCode } from "./utils/statusCodeHelpers";
|
||||
import type { PhoneNumbersClient, SearchAvailablePhoneNumbersRequest } from "../../src/index.js";
|
||||
import { createRecordedClient, createRecordedClientWithToken } from "./utils/recordedClient.js";
|
||||
import { isClientErrorStatusCode } from "./utils/statusCodeHelpers.js";
|
||||
import { describe, it, assert, beforeEach, afterEach } from "vitest";
|
||||
|
||||
matrix([[true, false]], async function (useAad) {
|
||||
describe(`PhoneNumbersClient - lro - search${useAad ? " [AAD]" : ""}`, function () {
|
||||
let recorder: Recorder;
|
||||
let client: PhoneNumbersClient;
|
||||
const searchRequest: SearchAvailablePhoneNumbersRequest = {
|
||||
countryCode: "US",
|
||||
phoneNumberType: "tollFree",
|
||||
assignmentType: "application",
|
||||
capabilities: {
|
||||
sms: "none",
|
||||
calling: "outbound",
|
||||
},
|
||||
};
|
||||
matrix([[true, false]], async (useAad) => {
|
||||
const skipPhoneNumbersTests = env.COMMUNICATION_SKIP_INT_PHONENUMBERS_TESTS === "true";
|
||||
|
||||
before(function (this: Context) {
|
||||
const skipPhoneNumbersTests = env.COMMUNICATION_SKIP_INT_PHONENUMBERS_TESTS === "true";
|
||||
if (skipPhoneNumbersTests && !isPlaybackMode()) {
|
||||
this.skip();
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(async function (this: Context) {
|
||||
({ client, recorder } = useAad
|
||||
? await createRecordedClientWithToken(this)!
|
||||
: await createRecordedClient(this));
|
||||
});
|
||||
|
||||
afterEach(async function (this: Context) {
|
||||
if (!this.currentTest?.isPending()) {
|
||||
await recorder.stop();
|
||||
}
|
||||
});
|
||||
|
||||
it("can search for 1 available phone number by default", async function () {
|
||||
const searchPoller = await client.beginSearchAvailablePhoneNumbers(searchRequest);
|
||||
|
||||
const results = await searchPoller.pollUntilDone();
|
||||
assert.ok(searchPoller.getOperationState().isCompleted);
|
||||
assert.equal(results.phoneNumbers.length, 1);
|
||||
}).timeout(60000);
|
||||
|
||||
it("throws on invalid search request", async function () {
|
||||
// person and toll free is an invalid combination
|
||||
const invalidSearchRequest: SearchAvailablePhoneNumbersRequest = {
|
||||
describe(
|
||||
`PhoneNumbersClient - lro - search${useAad ? " [AAD]" : ""}`,
|
||||
{ skip: skipPhoneNumbersTests && !isPlaybackMode() },
|
||||
() => {
|
||||
let recorder: Recorder;
|
||||
let client: PhoneNumbersClient;
|
||||
const searchRequest: SearchAvailablePhoneNumbersRequest = {
|
||||
countryCode: "US",
|
||||
phoneNumberType: "tollFree",
|
||||
assignmentType: "person",
|
||||
assignmentType: "application",
|
||||
capabilities: {
|
||||
sms: "inbound+outbound",
|
||||
calling: "none",
|
||||
sms: "none",
|
||||
calling: "outbound",
|
||||
},
|
||||
};
|
||||
|
||||
try {
|
||||
const searchPoller = await client.beginSearchAvailablePhoneNumbers(invalidSearchRequest);
|
||||
await searchPoller.pollUntilDone();
|
||||
} catch (error: any) {
|
||||
assert.isTrue(
|
||||
isClientErrorStatusCode(error.statusCode),
|
||||
`Status code ${error.statusCode} does not indicate client error.`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
beforeEach(async (ctx) => {
|
||||
({ client, recorder } = useAad
|
||||
? await createRecordedClientWithToken(ctx)!
|
||||
: await createRecordedClient(ctx));
|
||||
});
|
||||
|
||||
assert.fail("beginSearchAvailablePhoneNumbers should have thrown an exception.");
|
||||
}).timeout(60000);
|
||||
});
|
||||
afterEach(async () => {
|
||||
await recorder.stop();
|
||||
});
|
||||
|
||||
it("can search for 1 available phone number by default", { timeout: 60000 }, async () => {
|
||||
const searchPoller = await client.beginSearchAvailablePhoneNumbers(searchRequest);
|
||||
|
||||
const results = await searchPoller.pollUntilDone();
|
||||
assert.ok(searchPoller.getOperationState().isCompleted);
|
||||
assert.equal(results.phoneNumbers.length, 1);
|
||||
});
|
||||
|
||||
it("throws on invalid search request", { timeout: 60000 }, async () => {
|
||||
// person and toll free is an invalid combination
|
||||
const invalidSearchRequest: SearchAvailablePhoneNumbersRequest = {
|
||||
countryCode: "US",
|
||||
phoneNumberType: "tollFree",
|
||||
assignmentType: "person",
|
||||
capabilities: {
|
||||
sms: "inbound+outbound",
|
||||
calling: "none",
|
||||
},
|
||||
};
|
||||
|
||||
try {
|
||||
const searchPoller = await client.beginSearchAvailablePhoneNumbers(invalidSearchRequest);
|
||||
await searchPoller.pollUntilDone();
|
||||
} catch (error: any) {
|
||||
assert.isTrue(
|
||||
isClientErrorStatusCode(error.statusCode),
|
||||
`Status code ${error.statusCode} does not indicate client error.`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
assert.fail("beginSearchAvailablePhoneNumbers should have thrown an exception.");
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,101 +1,96 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import { matrix } from "@azure-tools/test-utils";
|
||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import { env, isPlaybackMode } from "@azure-tools/test-recorder";
|
||||
import { assert } from "chai";
|
||||
import type { Context } from "mocha";
|
||||
import type { PhoneNumberCapabilitiesRequest, PhoneNumbersClient } from "../../src";
|
||||
import { createRecordedClient, createRecordedClientWithToken } from "./utils/recordedClient";
|
||||
import { getPhoneNumber } from "./utils/testPhoneNumber";
|
||||
import { isClientErrorStatusCode } from "./utils/statusCodeHelpers";
|
||||
import type { PhoneNumberCapabilitiesRequest, PhoneNumbersClient } from "../../src/index.js";
|
||||
import { createRecordedClient, createRecordedClientWithToken } from "./utils/recordedClient.js";
|
||||
import { getPhoneNumber } from "./utils/testPhoneNumber.js";
|
||||
import { isClientErrorStatusCode } from "./utils/statusCodeHelpers.js";
|
||||
import { describe, it, assert, beforeEach, afterEach } from "vitest";
|
||||
|
||||
matrix([[true, false]], async function (useAad) {
|
||||
describe(`PhoneNumbersClient - lro - update${useAad ? " [AAD]" : ""}`, function () {
|
||||
const purchasedPhoneNumber = getPhoneNumber();
|
||||
const update: PhoneNumberCapabilitiesRequest = { calling: "none", sms: "outbound" };
|
||||
let recorder: Recorder;
|
||||
let client: PhoneNumbersClient;
|
||||
matrix([[true, false]], async (useAad) => {
|
||||
const skipPhoneNumbersTests =
|
||||
!isPlaybackMode() && env.COMMUNICATION_SKIP_INT_PHONENUMBERS_TESTS === "true";
|
||||
const skipUpdateCapabilitiesLiveTests =
|
||||
!isPlaybackMode() && env.SKIP_UPDATE_CAPABILITIES_LIVE_TESTS === "true";
|
||||
|
||||
before(function (this: Context) {
|
||||
const skipPhoneNumbersTests =
|
||||
!isPlaybackMode() && env.COMMUNICATION_SKIP_INT_PHONENUMBERS_TESTS === "true";
|
||||
const skipUpdateCapabilitiesLiveTests =
|
||||
!isPlaybackMode() && env.SKIP_UPDATE_CAPABILITIES_LIVE_TESTS === "true";
|
||||
describe(
|
||||
`PhoneNumbersClient - lro - update${useAad ? " [AAD]" : ""}`,
|
||||
{ skip: skipPhoneNumbersTests || skipUpdateCapabilitiesLiveTests },
|
||||
() => {
|
||||
const purchasedPhoneNumber = getPhoneNumber();
|
||||
const update: PhoneNumberCapabilitiesRequest = { calling: "none", sms: "outbound" };
|
||||
let recorder: Recorder;
|
||||
let client: PhoneNumbersClient;
|
||||
|
||||
if (skipPhoneNumbersTests || skipUpdateCapabilitiesLiveTests) {
|
||||
this.skip();
|
||||
}
|
||||
});
|
||||
beforeEach(async (ctx) => {
|
||||
({ client, recorder } = useAad
|
||||
? await createRecordedClientWithToken(ctx)!
|
||||
: await createRecordedClient(ctx));
|
||||
});
|
||||
|
||||
beforeEach(async function (this: Context) {
|
||||
({ client, recorder } = useAad
|
||||
? await createRecordedClientWithToken(this)!
|
||||
: await createRecordedClient(this));
|
||||
});
|
||||
|
||||
afterEach(async function (this: Context) {
|
||||
if (!this.currentTest?.isPending()) {
|
||||
afterEach(async () => {
|
||||
await recorder.stop();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("can update a phone number's capabilities", async function () {
|
||||
const updatePoller = await client.beginUpdatePhoneNumberCapabilities(
|
||||
purchasedPhoneNumber,
|
||||
update,
|
||||
);
|
||||
|
||||
const phoneNumber = await updatePoller.pollUntilDone();
|
||||
await updatePoller.pollUntilDone();
|
||||
assert.ok(updatePoller.getOperationState().isCompleted);
|
||||
assert.deepEqual(phoneNumber.capabilities, update);
|
||||
}).timeout(120000);
|
||||
|
||||
it("update throws when phone number is unauthorized", async function () {
|
||||
const fakeNumber = "+14155550100";
|
||||
try {
|
||||
const searchPoller = await client.beginUpdatePhoneNumberCapabilities(fakeNumber, update);
|
||||
await searchPoller.pollUntilDone();
|
||||
} catch (error: any) {
|
||||
assert.isTrue(
|
||||
isClientErrorStatusCode(error.statusCode),
|
||||
`Status code ${error.statusCode} does not indicate client error.`,
|
||||
it("can update a phone number's capabilities", { timeout: 120000 }, async () => {
|
||||
const updatePoller = await client.beginUpdatePhoneNumberCapabilities(
|
||||
purchasedPhoneNumber,
|
||||
update,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
assert.fail("beginUpdatePhoneNumberCapabilities should have thrown an exception.");
|
||||
});
|
||||
const phoneNumber = await updatePoller.pollUntilDone();
|
||||
await updatePoller.pollUntilDone();
|
||||
assert.ok(updatePoller.getOperationState().isCompleted);
|
||||
assert.deepEqual(phoneNumber.capabilities, update);
|
||||
});
|
||||
|
||||
it("update throws when phone number is invalid", async function () {
|
||||
const fakeNumber = "invalid_phone_number";
|
||||
try {
|
||||
const searchPoller = await client.beginUpdatePhoneNumberCapabilities(fakeNumber, update);
|
||||
await searchPoller.pollUntilDone();
|
||||
} catch (error: any) {
|
||||
assert.isTrue(
|
||||
isClientErrorStatusCode(error.statusCode),
|
||||
`Status code ${error.statusCode} does not indicate client error.`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
it("update throws when phone number is unauthorized", async () => {
|
||||
const fakeNumber = "+14155550100";
|
||||
try {
|
||||
const searchPoller = await client.beginUpdatePhoneNumberCapabilities(fakeNumber, update);
|
||||
await searchPoller.pollUntilDone();
|
||||
} catch (error: any) {
|
||||
assert.isTrue(
|
||||
isClientErrorStatusCode(error.statusCode),
|
||||
`Status code ${error.statusCode} does not indicate client error.`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
assert.fail("beginUpdatePhoneNumberCapabilities should have thrown an exception.");
|
||||
});
|
||||
assert.fail("beginUpdatePhoneNumberCapabilities should have thrown an exception.");
|
||||
});
|
||||
|
||||
it("update throws when phone number is empty", async function () {
|
||||
const fakeNumber = "";
|
||||
try {
|
||||
const searchPoller = await client.beginUpdatePhoneNumberCapabilities(fakeNumber, update);
|
||||
await searchPoller.pollUntilDone();
|
||||
} catch (error: any) {
|
||||
assert.equal(error.message, "phone number can't be empty");
|
||||
return;
|
||||
}
|
||||
it("update throws when phone number is invalid", async () => {
|
||||
const fakeNumber = "invalid_phone_number";
|
||||
try {
|
||||
const searchPoller = await client.beginUpdatePhoneNumberCapabilities(fakeNumber, update);
|
||||
await searchPoller.pollUntilDone();
|
||||
} catch (error: any) {
|
||||
assert.isTrue(
|
||||
isClientErrorStatusCode(error.statusCode),
|
||||
`Status code ${error.statusCode} does not indicate client error.`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
assert.fail("beginUpdatePhoneNumberCapabilities should have thrown an exception.");
|
||||
});
|
||||
});
|
||||
assert.fail("beginUpdatePhoneNumberCapabilities should have thrown an exception.");
|
||||
});
|
||||
|
||||
it("update throws when phone number is empty", async () => {
|
||||
const fakeNumber = "";
|
||||
try {
|
||||
const searchPoller = await client.beginUpdatePhoneNumberCapabilities(fakeNumber, update);
|
||||
await searchPoller.pollUntilDone();
|
||||
} catch (error: any) {
|
||||
assert.equal(error.message, "phone number can't be empty");
|
||||
return;
|
||||
}
|
||||
|
||||
assert.fail("beginUpdatePhoneNumberCapabilities should have thrown an exception.");
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -2,27 +2,24 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import { assert } from "chai";
|
||||
import type { Context } from "mocha";
|
||||
import type { PhoneNumbersClient } from "../../src";
|
||||
import { createRecordedClient } from "./utils/recordedClient";
|
||||
import { getPhoneNumber } from "./utils/testPhoneNumber";
|
||||
import type { PhoneNumbersClient } from "../../src/index.js";
|
||||
import { createRecordedClient } from "./utils/recordedClient.js";
|
||||
import { getPhoneNumber } from "./utils/testPhoneNumber.js";
|
||||
import { describe, it, assert, beforeEach, afterEach } from "vitest";
|
||||
|
||||
describe(`PhoneNumbersClient - look up phone number`, function () {
|
||||
describe(`PhoneNumbersClient - look up phone number`, () => {
|
||||
let recorder: Recorder;
|
||||
let client: PhoneNumbersClient;
|
||||
|
||||
beforeEach(async function (this: Context) {
|
||||
({ client, recorder } = await createRecordedClient(this));
|
||||
beforeEach(async (ctx) => {
|
||||
({ client, recorder } = await createRecordedClient(ctx));
|
||||
});
|
||||
|
||||
afterEach(async function (this: Context) {
|
||||
if (!this.currentTest?.isPending()) {
|
||||
await recorder.stop();
|
||||
}
|
||||
afterEach(async () => {
|
||||
await recorder.stop();
|
||||
});
|
||||
|
||||
it("can look up a phone number", async function (this: Context) {
|
||||
it("can look up a phone number", { timeout: 60000 }, async () => {
|
||||
const phoneNumbers = [getPhoneNumber()];
|
||||
const operatorInformation = await client.searchOperatorInformation(phoneNumbers);
|
||||
|
||||
|
@ -30,9 +27,9 @@ describe(`PhoneNumbersClient - look up phone number`, function () {
|
|||
? operatorInformation.values[0].phoneNumber
|
||||
: "";
|
||||
assert.strictEqual(resultPhoneNumber, phoneNumbers[0]);
|
||||
}).timeout(60000);
|
||||
});
|
||||
|
||||
it("errors if multiple phone numbers are requested", async function () {
|
||||
it("errors if multiple phone numbers are requested", { timeout: 60000 }, async () => {
|
||||
const phoneNumbers = [getPhoneNumber(), getPhoneNumber()];
|
||||
try {
|
||||
await client.searchOperatorInformation(phoneNumbers);
|
||||
|
@ -40,9 +37,9 @@ describe(`PhoneNumbersClient - look up phone number`, function () {
|
|||
assert.strictEqual(error.code, "BadRequest");
|
||||
assert.strictEqual(error.message, "Can only accept one phoneNumber");
|
||||
}
|
||||
}).timeout(60000);
|
||||
});
|
||||
|
||||
it("respects includeAdditionalOperatorDetails option", async function (this: Context) {
|
||||
it("respects includeAdditionalOperatorDetails option", { timeout: 60000 }, async () => {
|
||||
const phoneNumbers = [getPhoneNumber()];
|
||||
|
||||
let operatorInformation = await client.searchOperatorInformation(phoneNumbers, {
|
||||
|
@ -82,5 +79,5 @@ describe(`PhoneNumbersClient - look up phone number`, function () {
|
|||
assert.isNotNull(
|
||||
operatorInformation.values ? operatorInformation.values[0].operatorDetails : null,
|
||||
);
|
||||
}).timeout(60000);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,36 +1,33 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import { matrix } from "@azure-tools/test-utils";
|
||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import { assert } from "chai";
|
||||
import type { Context } from "mocha";
|
||||
import type { PhoneNumbersClient } from "../../src";
|
||||
import { createRecordedClient, createRecordedClientWithToken } from "./utils/recordedClient";
|
||||
import type { PhoneNumbersClient } from "../../src/index.js";
|
||||
import { createRecordedClient, createRecordedClientWithToken } from "./utils/recordedClient.js";
|
||||
import { describe, it, assert, beforeEach, afterEach } from "vitest";
|
||||
|
||||
matrix([[true, false]], async function (useAad) {
|
||||
describe(`PhoneNumbersClient - offerings lists${useAad ? " [AAD]" : ""}`, function () {
|
||||
matrix([[true, false]], async (useAad) => {
|
||||
describe(`PhoneNumbersClient - offerings lists${useAad ? " [AAD]" : ""}`, () => {
|
||||
let recorder: Recorder;
|
||||
let client: PhoneNumbersClient;
|
||||
|
||||
beforeEach(async function (this: Context) {
|
||||
beforeEach(async (ctx) => {
|
||||
({ client, recorder } = useAad
|
||||
? await createRecordedClientWithToken(this)!
|
||||
: await createRecordedClient(this));
|
||||
? await createRecordedClientWithToken(ctx)!
|
||||
: await createRecordedClient(ctx));
|
||||
});
|
||||
|
||||
afterEach(async function (this: Context) {
|
||||
if (!this.currentTest?.isPending()) {
|
||||
await recorder.stop();
|
||||
}
|
||||
afterEach(async () => {
|
||||
await recorder.stop();
|
||||
});
|
||||
|
||||
it("can list available offerings", async function () {
|
||||
it("can list available offerings", { timeout: 60000 }, async () => {
|
||||
const responseOfferings = [];
|
||||
for await (const offering of client.listAvailableOfferings("US")) {
|
||||
responseOfferings.push(offering);
|
||||
}
|
||||
assert.isNotEmpty(responseOfferings);
|
||||
}).timeout(60000);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,32 +2,31 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
import { AzureKeyCredential } from "@azure/core-auth";
|
||||
import { assert } from "chai";
|
||||
import type { Context } from "mocha";
|
||||
import { SipRoutingClient } from "../../../src";
|
||||
import { createMockToken } from "./utils/recordedClient";
|
||||
import { SipRoutingClient } from "../../../src/index.js";
|
||||
import { createMockToken } from "./utils/recordedClient.js";
|
||||
import { describe, it, assert } from "vitest";
|
||||
|
||||
describe("SipRoutingClient - constructor", function () {
|
||||
describe("SipRoutingClient - constructor", () => {
|
||||
const endpoint = "https://contoso.spool.azure.local";
|
||||
const accessKey = "accessKey";
|
||||
|
||||
it("successfully instantiates with valid connection string", function () {
|
||||
it("successfully instantiates with valid connection string", () => {
|
||||
const client = new SipRoutingClient(`endpoint=${endpoint};accesskey=${accessKey}`);
|
||||
assert.instanceOf(client, SipRoutingClient);
|
||||
});
|
||||
|
||||
it("throws with invalid connection string", function () {
|
||||
it("throws with invalid connection string", () => {
|
||||
assert.throws(() => {
|
||||
new SipRoutingClient(`endpoints=${endpoint};accesskey=${accessKey}`);
|
||||
});
|
||||
});
|
||||
|
||||
it("successfully instantiates with with endpoint and access key", function () {
|
||||
it("successfully instantiates with with endpoint and access key", () => {
|
||||
const client = new SipRoutingClient(endpoint, new AzureKeyCredential(accessKey));
|
||||
assert.instanceOf(client, SipRoutingClient);
|
||||
});
|
||||
|
||||
it("successfully instantiates with with endpoint and managed identity", function (this: Context) {
|
||||
it("successfully instantiates with with endpoint and managed identity", () => {
|
||||
const client = new SipRoutingClient(endpoint, createMockToken());
|
||||
assert.instanceOf(client, SipRoutingClient);
|
||||
});
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import { assert } from "chai";
|
||||
import type { Context } from "mocha";
|
||||
|
||||
import type { SipRoutingClient } from "../../../src";
|
||||
|
||||
import type { SipRoutingClient } from "../../../src/index.js";
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import { isPlaybackMode } from "@azure-tools/test-recorder";
|
||||
import type { SipTrunk } from "../../../src/models";
|
||||
import type { SipTrunk } from "../../../src/models.js";
|
||||
import {
|
||||
clearSipConfiguration,
|
||||
createRecordedClient,
|
||||
|
@ -16,32 +12,31 @@ import {
|
|||
getUniqueFqdn,
|
||||
listAllTrunks,
|
||||
resetUniqueFqdns,
|
||||
} from "./utils/recordedClient";
|
||||
import { matrix } from "@azure-tools/test-utils";
|
||||
} from "./utils/recordedClient.js";
|
||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||
import { describe, it, assert, beforeEach, afterEach, beforeAll } from "vitest";
|
||||
|
||||
matrix([[true, false]], async function (useAad) {
|
||||
describe(`SipRoutingClient - delete trunk${useAad ? " [AAD]" : ""}`, function () {
|
||||
matrix([[true, false]], async (useAad) => {
|
||||
describe(`SipRoutingClient - delete trunk${useAad ? " [AAD]" : ""}`, () => {
|
||||
let client: SipRoutingClient;
|
||||
let recorder: Recorder;
|
||||
let testFqdn = "";
|
||||
|
||||
before(async function (this: Context) {
|
||||
beforeAll(async () => {
|
||||
if (!isPlaybackMode()) {
|
||||
await clearSipConfiguration();
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(async function (this: Context) {
|
||||
beforeEach(async (ctx) => {
|
||||
({ client, recorder } = useAad
|
||||
? await createRecordedClientWithToken(this)
|
||||
: await createRecordedClient(this));
|
||||
? await createRecordedClientWithToken(ctx)
|
||||
: await createRecordedClient(ctx));
|
||||
testFqdn = getUniqueFqdn(recorder);
|
||||
});
|
||||
|
||||
afterEach(async function (this: Context) {
|
||||
if (!this.currentTest?.isPending()) {
|
||||
await recorder.stop();
|
||||
}
|
||||
afterEach(async () => {
|
||||
await recorder.stop();
|
||||
resetUniqueFqdns();
|
||||
});
|
||||
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import type { SipRoutingClient } from "../../../src/index.js";
|
||||
|
||||
import { assert } from "chai";
|
||||
import type { Context } from "mocha";
|
||||
|
||||
import type { SipRoutingClient } from "../../../src";
|
||||
|
||||
import { matrix } from "@azure-tools/test-utils";
|
||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import { isPlaybackMode } from "@azure-tools/test-recorder";
|
||||
import {
|
||||
|
@ -14,29 +10,28 @@ import {
|
|||
createRecordedClient,
|
||||
createRecordedClientWithToken,
|
||||
listAllRoutes,
|
||||
} from "./utils/recordedClient";
|
||||
} from "./utils/recordedClient.js";
|
||||
import { describe, it, assert, beforeEach, afterEach, beforeAll } from "vitest";
|
||||
|
||||
matrix([[true, false]], async function (useAad) {
|
||||
describe(`SipRoutingClient - get routes${useAad ? " [AAD]" : ""}`, function () {
|
||||
matrix([[true, false]], async (useAad) => {
|
||||
describe(`SipRoutingClient - get routes${useAad ? " [AAD]" : ""}`, () => {
|
||||
let client: SipRoutingClient;
|
||||
let recorder: Recorder;
|
||||
|
||||
before(async function (this: Context) {
|
||||
beforeAll(async () => {
|
||||
if (!isPlaybackMode()) {
|
||||
await clearSipConfiguration();
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(async function (this: Context) {
|
||||
beforeEach(async (ctx) => {
|
||||
({ client, recorder } = useAad
|
||||
? await createRecordedClientWithToken(this)
|
||||
: await createRecordedClient(this));
|
||||
? await createRecordedClientWithToken(ctx)
|
||||
: await createRecordedClient(ctx));
|
||||
});
|
||||
|
||||
afterEach(async function (this: Context) {
|
||||
if (!this.currentTest?.isPending()) {
|
||||
await recorder.stop();
|
||||
}
|
||||
afterEach(async () => {
|
||||
await recorder.stop();
|
||||
});
|
||||
|
||||
it("can retrieve routes", async () => {
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import { assert } from "chai";
|
||||
import type { Context } from "mocha";
|
||||
|
||||
import type { SipRoutingClient } from "../../../src";
|
||||
import type { SipRoutingClient } from "../../../src/index.js";
|
||||
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import { isPlaybackMode } from "@azure-tools/test-recorder";
|
||||
import type { SipTrunk } from "../../../src/models";
|
||||
import type { SipTrunk } from "../../../src/models.js";
|
||||
import {
|
||||
clearSipConfiguration,
|
||||
createRecordedClient,
|
||||
|
@ -16,11 +12,12 @@ import {
|
|||
getUniqueFqdn,
|
||||
listAllTrunks,
|
||||
resetUniqueFqdns,
|
||||
} from "./utils/recordedClient";
|
||||
import { matrix } from "@azure-tools/test-utils";
|
||||
} from "./utils/recordedClient.js";
|
||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||
import { describe, it, assert, beforeEach, afterEach, beforeAll } from "vitest";
|
||||
|
||||
matrix([[true, false]], async function (useAad) {
|
||||
describe(`SipRoutingClient - get trunks${useAad ? " [AAD]" : ""}`, function () {
|
||||
matrix([[true, false]], async (useAad) => {
|
||||
describe(`SipRoutingClient - get trunks${useAad ? " [AAD]" : ""}`, () => {
|
||||
let client: SipRoutingClient;
|
||||
let recorder: Recorder;
|
||||
let firstFqdn = "";
|
||||
|
@ -28,26 +25,24 @@ matrix([[true, false]], async function (useAad) {
|
|||
let thirdFqdn = "";
|
||||
let fourthFqdn = "";
|
||||
|
||||
before(async function (this: Context) {
|
||||
beforeAll(async () => {
|
||||
if (!isPlaybackMode()) {
|
||||
await clearSipConfiguration();
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(async function (this: Context) {
|
||||
beforeEach(async (ctx) => {
|
||||
({ client, recorder } = useAad
|
||||
? await createRecordedClientWithToken(this)
|
||||
: await createRecordedClient(this));
|
||||
? await createRecordedClientWithToken(ctx)
|
||||
: await createRecordedClient(ctx));
|
||||
firstFqdn = getUniqueFqdn(recorder);
|
||||
secondFqdn = getUniqueFqdn(recorder);
|
||||
thirdFqdn = getUniqueFqdn(recorder);
|
||||
fourthFqdn = getUniqueFqdn(recorder);
|
||||
});
|
||||
|
||||
afterEach(async function (this: Context) {
|
||||
if (!this.currentTest?.isPending()) {
|
||||
await recorder.stop();
|
||||
}
|
||||
afterEach(async () => {
|
||||
await recorder.stop();
|
||||
resetUniqueFqdns();
|
||||
});
|
||||
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import { assert } from "chai";
|
||||
import type { Context } from "mocha";
|
||||
|
||||
import type { SipRoutingClient } from "../../../src";
|
||||
import type { SipRoutingClient } from "../../../src/index.js";
|
||||
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import { isPlaybackMode } from "@azure-tools/test-recorder";
|
||||
import type { SipTrunk, SipTrunkRoute } from "../../../src/models";
|
||||
import type { SipTrunk, SipTrunkRoute } from "../../../src/models.js";
|
||||
import {
|
||||
clearSipConfiguration,
|
||||
createRecordedClient,
|
||||
|
@ -17,34 +13,33 @@ import {
|
|||
listAllRoutes,
|
||||
listAllTrunks,
|
||||
resetUniqueFqdns,
|
||||
} from "./utils/recordedClient";
|
||||
import { matrix } from "@azure-tools/test-utils";
|
||||
} from "./utils/recordedClient.js";
|
||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||
import { describe, it, assert, beforeEach, afterEach, beforeAll } from "vitest";
|
||||
|
||||
matrix([[true, false]], async function (useAad) {
|
||||
describe(`SipRoutingClient - set routes${useAad ? " [AAD]" : ""}`, function () {
|
||||
matrix([[true, false]], async (useAad) => {
|
||||
describe(`SipRoutingClient - set routes${useAad ? " [AAD]" : ""}`, () => {
|
||||
let client: SipRoutingClient;
|
||||
let recorder: Recorder;
|
||||
let firstFqdn = "";
|
||||
let secondFqdn = "";
|
||||
|
||||
before(async function (this: Context) {
|
||||
beforeAll(async () => {
|
||||
if (!isPlaybackMode()) {
|
||||
await clearSipConfiguration();
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(async function (this: Context) {
|
||||
beforeEach(async (ctx) => {
|
||||
({ client, recorder } = useAad
|
||||
? await createRecordedClientWithToken(this)
|
||||
: await createRecordedClient(this));
|
||||
? await createRecordedClientWithToken(ctx)
|
||||
: await createRecordedClient(ctx));
|
||||
firstFqdn = getUniqueFqdn(recorder);
|
||||
secondFqdn = getUniqueFqdn(recorder);
|
||||
});
|
||||
|
||||
afterEach(async function (this: Context) {
|
||||
if (!this.currentTest?.isPending()) {
|
||||
await recorder.stop();
|
||||
}
|
||||
afterEach(async () => {
|
||||
await recorder.stop();
|
||||
resetUniqueFqdns();
|
||||
});
|
||||
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import { assert } from "chai";
|
||||
import type { Context } from "mocha";
|
||||
|
||||
import type { SipRoutingClient } from "../../../src";
|
||||
import type { SipRoutingClient } from "../../../src/index.js";
|
||||
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import { isPlaybackMode } from "@azure-tools/test-recorder";
|
||||
import type { SipTrunk, SipTrunkRoute } from "../../../src/models";
|
||||
import type { SipTrunk, SipTrunkRoute } from "../../../src/models.js";
|
||||
import {
|
||||
clearSipConfiguration,
|
||||
createRecordedClient,
|
||||
|
@ -17,34 +13,33 @@ import {
|
|||
listAllRoutes,
|
||||
listAllTrunks,
|
||||
resetUniqueFqdns,
|
||||
} from "./utils/recordedClient";
|
||||
import { matrix } from "@azure-tools/test-utils";
|
||||
} from "./utils/recordedClient.js";
|
||||
import { matrix } from "@azure-tools/test-utils-vitest";
|
||||
import { describe, it, assert, beforeEach, afterEach, beforeAll } from "vitest";
|
||||
|
||||
matrix([[true, false]], async function (useAad) {
|
||||
describe(`SipRoutingClient - set trunks${useAad ? " [AAD]" : ""}`, function () {
|
||||
matrix([[true, false]], async (useAad) => {
|
||||
describe(`SipRoutingClient - set trunks${useAad ? " [AAD]" : ""}`, () => {
|
||||
let client: SipRoutingClient;
|
||||
let recorder: Recorder;
|
||||
let firstFqdn = "";
|
||||
let secondFqdn = "";
|
||||
|
||||
before(async function (this: Context) {
|
||||
beforeAll(async () => {
|
||||
if (!isPlaybackMode()) {
|
||||
await clearSipConfiguration();
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(async function (this: Context) {
|
||||
beforeEach(async (ctx) => {
|
||||
({ client, recorder } = useAad
|
||||
? await createRecordedClientWithToken(this)
|
||||
: await createRecordedClient(this));
|
||||
? await createRecordedClientWithToken(ctx)
|
||||
: await createRecordedClient(ctx));
|
||||
firstFqdn = getUniqueFqdn(recorder);
|
||||
secondFqdn = getUniqueFqdn(recorder);
|
||||
});
|
||||
|
||||
afterEach(async function (this: Context) {
|
||||
if (!this.currentTest?.isPending()) {
|
||||
await recorder.stop();
|
||||
}
|
||||
afterEach(async () => {
|
||||
await recorder.stop();
|
||||
resetUniqueFqdns();
|
||||
});
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import type {
|
|||
PipelineRequest,
|
||||
PipelineResponse,
|
||||
} from "@azure/core-rest-pipeline";
|
||||
import type { SipTrunk } from "../../../../src";
|
||||
import type { SipTrunk } from "../../../../src/index.js";
|
||||
|
||||
export const createMockHttpClient = <T = Record<string, unknown>>(
|
||||
status: number = 200,
|
||||
|
|
|
@ -1,24 +1,22 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import type { Context, Test } from "mocha";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
import type { RecorderStartOptions, SanitizerOptions } from "@azure-tools/test-recorder";
|
||||
import type { RecorderStartOptions, SanitizerOptions, TestInfo } from "@azure-tools/test-recorder";
|
||||
import {
|
||||
Recorder,
|
||||
assertEnvironmentVariable,
|
||||
env,
|
||||
isPlaybackMode,
|
||||
} from "@azure-tools/test-recorder";
|
||||
import type { SipTrunk, SipTrunkRoute } from "../../../../src";
|
||||
import { SipRoutingClient } from "../../../../src";
|
||||
import type { SipTrunk, SipTrunkRoute } from "../../../../src/index.js";
|
||||
import { SipRoutingClient } from "../../../../src/index.js";
|
||||
import { parseConnectionString } from "@azure/communication-common";
|
||||
import type { TokenCredential } from "@azure/identity";
|
||||
import { isNodeLike } from "@azure/core-util";
|
||||
import { createTestCredential } from "@azure-tools/test-credential";
|
||||
import { randomUUID } from "@azure/core-util";
|
||||
import { createMSUserAgentPolicy } from "./msUserAgentPolicy";
|
||||
import { createMSUserAgentPolicy } from "./msUserAgentPolicy.js";
|
||||
|
||||
if (isNodeLike) {
|
||||
dotenv.config();
|
||||
|
@ -70,7 +68,7 @@ const recorderOptions: RecorderStartOptions = {
|
|||
],
|
||||
};
|
||||
|
||||
export async function createRecorder(context: Test | undefined): Promise<Recorder> {
|
||||
export async function createRecorder(context: TestInfo | undefined): Promise<Recorder> {
|
||||
const recorder = new Recorder(context);
|
||||
await recorder.start(recorderOptions);
|
||||
await recorder.setMatcher("CustomDefaultMatcher", {
|
||||
|
@ -83,9 +81,9 @@ export async function createRecorder(context: Test | undefined): Promise<Recorde
|
|||
}
|
||||
|
||||
export async function createRecordedClient(
|
||||
context: Context,
|
||||
context: TestInfo,
|
||||
): Promise<RecordedClient<SipRoutingClient>> {
|
||||
const recorder = await createRecorder(context.currentTest);
|
||||
const recorder = await createRecorder(context);
|
||||
|
||||
const client = new SipRoutingClient(
|
||||
assertEnvironmentVariable("COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING"),
|
||||
|
@ -111,9 +109,9 @@ export function createMockToken(): TokenCredential {
|
|||
}
|
||||
|
||||
export async function createRecordedClientWithToken(
|
||||
context: Context,
|
||||
context: TestInfo,
|
||||
): Promise<RecordedClient<SipRoutingClient>> {
|
||||
const recorder = await createRecorder(context.currentTest);
|
||||
const recorder = await createRecorder(context);
|
||||
|
||||
let credential: TokenCredential;
|
||||
const endpoint = parseConnectionString(
|
||||
|
|
|
@ -7,8 +7,8 @@ import type {
|
|||
PipelineRequest,
|
||||
PipelineResponse,
|
||||
} from "@azure/core-rest-pipeline";
|
||||
import type { PurchasedPhoneNumber } from "../../../src";
|
||||
import type { PurchasedPhoneNumbers } from "../../../src/generated/src/models";
|
||||
import type { PurchasedPhoneNumber } from "../../../src/index.js";
|
||||
import type { PurchasedPhoneNumbers } from "../../../src/generated/src/models/index.js";
|
||||
|
||||
export const createMockHttpClient = <T = Record<string, unknown>>(
|
||||
status: number = 200,
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import type { Context, Test } from "mocha";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
import type { RecorderStartOptions, SanitizerOptions } from "@azure-tools/test-recorder";
|
||||
import type { RecorderStartOptions, SanitizerOptions, TestInfo } from "@azure-tools/test-recorder";
|
||||
import { Recorder, env, isPlaybackMode } from "@azure-tools/test-recorder";
|
||||
import { PhoneNumbersClient } from "../../../src";
|
||||
import { PhoneNumbersClient } from "../../../src/index.js";
|
||||
import { parseConnectionString } from "@azure/communication-common";
|
||||
import type { TokenCredential } from "@azure/identity";
|
||||
import { isNode } from "@azure-tools/test-utils";
|
||||
import { isNodeLike } from "@azure/core-util";
|
||||
import { createTestCredential } from "@azure-tools/test-credential";
|
||||
import { createMSUserAgentPolicy } from "./msUserAgentPolicy";
|
||||
import { createMSUserAgentPolicy } from "./msUserAgentPolicy.js";
|
||||
|
||||
if (isNode) {
|
||||
if (isNodeLike) {
|
||||
dotenv.config();
|
||||
}
|
||||
|
||||
|
@ -68,7 +66,7 @@ const recorderOptions: RecorderStartOptions = {
|
|||
],
|
||||
};
|
||||
|
||||
export async function createRecorder(context: Test | undefined): Promise<Recorder> {
|
||||
export async function createRecorder(context: TestInfo | undefined): Promise<Recorder> {
|
||||
const recorder = new Recorder(context);
|
||||
await recorder.start(recorderOptions);
|
||||
await recorder.setMatcher("CustomDefaultMatcher", {
|
||||
|
@ -81,9 +79,9 @@ export async function createRecorder(context: Test | undefined): Promise<Recorde
|
|||
}
|
||||
|
||||
export async function createRecordedClient(
|
||||
context: Context,
|
||||
context: TestInfo,
|
||||
): Promise<RecordedClient<PhoneNumbersClient>> {
|
||||
const recorder = await createRecorder(context.currentTest);
|
||||
const recorder = await createRecorder(context);
|
||||
|
||||
const client = new PhoneNumbersClient(
|
||||
env.COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING ?? "",
|
||||
|
@ -110,9 +108,9 @@ export function createMockToken(): TokenCredential {
|
|||
}
|
||||
|
||||
export async function createRecordedClientWithToken(
|
||||
context: Context,
|
||||
context: TestInfo,
|
||||
): Promise<RecordedClient<PhoneNumbersClient>> {
|
||||
const recorder = await createRecorder(context.currentTest);
|
||||
const recorder = await createRecorder(context);
|
||||
|
||||
let credential: TokenCredential;
|
||||
const endpoint = parseConnectionString(
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
import { env, isPlaybackMode } from "@azure-tools/test-recorder";
|
||||
|
||||
const DEFAULT_PHONE_NUMBER = "+14155550100";
|
||||
const testAgentPhoneNumber = () => env[`AZURE_PHONE_NUMBER_${env.AZURE_TEST_AGENT}`] ?? "";
|
||||
const defaultTestPhoneNumber = () => env.AZURE_PHONE_NUMBER ?? "";
|
||||
const testAgentPhoneNumber = (): string => env[`AZURE_PHONE_NUMBER_${env.AZURE_TEST_AGENT}`] ?? "";
|
||||
const defaultTestPhoneNumber = (): string => env.AZURE_PHONE_NUMBER ?? "";
|
||||
|
||||
export function getPhoneNumber(): string {
|
||||
return isPlaybackMode() ? DEFAULT_PHONE_NUMBER : getPhoneNumberFromEnvironment();
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"extends": "./.tshy/build.json",
|
||||
"include": ["./src/**/*.ts", "./src/**/*.mts", "./test/**/*.spec.ts", "./test/**/*.mts"],
|
||||
"exclude": ["./test/**/node/**/*.ts"],
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist-test/browser",
|
||||
"rootDir": ".",
|
||||
"skipLibCheck": true
|
||||
}
|
||||
}
|
|
@ -1,11 +1,12 @@
|
|||
{
|
||||
"extends": "../../../tsconfig",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist-esm",
|
||||
"declarationDir": "./types",
|
||||
"paths": {
|
||||
"@azure/communication-phone-numbers": ["./src/index"]
|
||||
}
|
||||
},
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"rootDir": "."
|
||||
},
|
||||
"include": ["src/**/*.ts", "test/**/*.ts", "samples-dev/**/*.ts"]
|
||||
"include": ["src/**/*.ts", "src/**/*.mts", "src/**/*.cts", "samples-dev/**/*.ts", "test/**/*.ts"]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import { defineConfig, mergeConfig } from "vitest/config";
|
||||
import viteConfig from "../../../vitest.browser.shared.config.ts";
|
||||
|
||||
export default mergeConfig(
|
||||
viteConfig,
|
||||
defineConfig({
|
||||
test: {
|
||||
include: ["dist-test/browser/test/**/*.spec.js"],
|
||||
hookTimeout: 5000000,
|
||||
testTimeout: 5000000,
|
||||
},
|
||||
}),
|
||||
);
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import { defineConfig, mergeConfig } from "vitest/config";
|
||||
import viteConfig from "../../../vitest.shared.config.ts";
|
||||
|
||||
export default mergeConfig(
|
||||
viteConfig,
|
||||
defineConfig({
|
||||
test: {
|
||||
include: ["test/**/*.spec.ts"],
|
||||
hookTimeout: 5000000,
|
||||
testTimeout: 5000000,
|
||||
},
|
||||
}),
|
||||
);
|
Загрузка…
Ссылка в новой задаче