1
1
import shortid from "shortid" ;
2
2
import _ from "lodash" ;
3
- import { AzureCustomVisionProvider , IAzureCustomVisionExportOptions , NewOrExisting } from "./azureCustomVision" ;
3
+ import {
4
+ AzureCustomVisionProvider , IAzureCustomVisionExportOptions ,
5
+ NewOrExisting , AzureRegion ,
6
+ } from "./azureCustomVision" ;
4
7
import registerProviders from "../../registerProviders" ;
5
8
import { ExportProviderFactory } from "./exportProviderFactory" ;
6
9
import MockFactory from "../../common/mockFactory" ;
@@ -29,6 +32,7 @@ describe("Azure Custom Vision Export Provider", () => {
29
32
let testProject : IProject = null ;
30
33
const defaultOptions : IAzureCustomVisionExportOptions = {
31
34
apiKey : expect . any ( String ) ,
35
+ region : AzureRegion . SouthCentralUS ,
32
36
assetState : ExportAssetState . All ,
33
37
newOrExisting : NewOrExisting . New ,
34
38
projectId : expect . any ( String ) ,
@@ -64,6 +68,7 @@ describe("Azure Custom Vision Export Provider", () => {
64
68
assetState : ExportAssetState . All ,
65
69
projectId : "azure-custom-vision-project-1" ,
66
70
apiKey : "ABC123" ,
71
+ region : AzureRegion . SouthCentralUS ,
67
72
} ,
68
73
} ,
69
74
} ;
@@ -81,6 +86,18 @@ describe("Azure Custom Vision Export Provider", () => {
81
86
expect ( provider ) . toBeInstanceOf ( AzureCustomVisionProvider ) ;
82
87
} ) ;
83
88
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
+
84
101
it ( "Calling save with New project creates Azure Custom Vision project" , async ( ) => {
85
102
const customVisionMock = AzureCustomVisionService as jest . Mocked < typeof AzureCustomVisionService > ;
86
103
customVisionMock . prototype . create = jest . fn ( ( project ) => {
0 commit comments