11import shortid from "shortid" ;
22import _ from "lodash" ;
3- import { AzureCustomVisionProvider , IAzureCustomVisionExportOptions , NewOrExisting } from "./azureCustomVision" ;
3+ import {
4+ AzureCustomVisionProvider , IAzureCustomVisionExportOptions ,
5+ NewOrExisting , AzureRegion ,
6+ } from "./azureCustomVision" ;
47import registerProviders from "../../registerProviders" ;
58import { ExportProviderFactory } from "./exportProviderFactory" ;
69import MockFactory from "../../common/mockFactory" ;
@@ -29,6 +32,7 @@ describe("Azure Custom Vision Export Provider", () => {
2932 let testProject : IProject = null ;
3033 const defaultOptions : IAzureCustomVisionExportOptions = {
3134 apiKey : expect . any ( String ) ,
35+ region : AzureRegion . SouthCentralUS ,
3236 assetState : ExportAssetState . All ,
3337 newOrExisting : NewOrExisting . New ,
3438 projectId : expect . any ( String ) ,
@@ -64,6 +68,7 @@ describe("Azure Custom Vision Export Provider", () => {
6468 assetState : ExportAssetState . All ,
6569 projectId : "azure-custom-vision-project-1" ,
6670 apiKey : "ABC123" ,
71+ region : AzureRegion . SouthCentralUS ,
6772 } ,
6873 } ,
6974 } ;
@@ -81,6 +86,18 @@ describe("Azure Custom Vision Export Provider", () => {
8186 expect ( provider ) . toBeInstanceOf ( AzureCustomVisionProvider ) ;
8287 } ) ;
8388
89+ it ( "Constructs custom vision service with correct options" , ( ) => {
90+ const customVisionMock = AzureCustomVisionService as jest . Mocked < typeof AzureCustomVisionService > ;
91+ const providerOptions = testProject . exportFormat . providerOptions as IAzureCustomVisionExportOptions ;
92+ providerOptions . region = AzureRegion . WestEurope ;
93+ createProvider ( testProject ) ;
94+
95+ expect ( customVisionMock ) . toBeCalledWith ( {
96+ apiKey : providerOptions . apiKey ,
97+ baseUrl : `https://${ providerOptions . region } .api.cognitive.microsoft.com/customvision/v2.2/Training` ,
98+ } ) ;
99+ } ) ;
100+
84101 it ( "Calling save with New project creates Azure Custom Vision project" , async ( ) => {
85102 const customVisionMock = AzureCustomVisionService as jest . Mocked < typeof AzureCustomVisionService > ;
86103 customVisionMock . prototype . create = jest . fn ( ( project ) => {
0 commit comments