1+ import { expect , test } from '@oclif/test'
2+ const sinon = require ( 'sinon' )
3+ const uuidv1 = require ( 'uuid/v1' )
4+ const utils = require ( '../../../../src/utils/index' )
5+
6+ describe ( 'luis:version:rename' , ( ) => {
7+
8+ beforeEach ( ( ) => {
9+ sinon . stub ( utils , 'processInputs' ) . returnsArg ( 0 )
10+ } )
11+
12+ afterEach ( ( ) => {
13+ sinon . restore ( ) ;
14+ } ) ;
15+
16+ test
17+ . stdout ( )
18+ . command ( [ 'luis:version:rename' , '--help' ] )
19+ . it ( 'should print the help contents when --help is passed as an argument' , ctx => {
20+ expect ( ctx . stdout ) . to . contain ( 'Renames application version' )
21+ } )
22+
23+ test
24+ . stdout ( )
25+ . stderr ( )
26+ . command ( [ 'luis:version:rename' , '--endpoint' , 'https://westus.api.cognitive.microsoft.com' , '--appId' , uuidv1 ( ) , '--subscriptionKey' , uuidv1 ( ) , '--versionId' , '0.1' , '--newVersionId' , '0.2' ] )
27+ . it ( 'displays an error if any required input parameters are missing' , ctx => {
28+ expect ( ctx . stderr ) . to . contain ( `Required input property 'name' missing.` )
29+ } )
30+
31+ test
32+ . stdout ( )
33+ . stderr ( )
34+ . command ( [ 'luis:version:rename' , '--endpoint' , 'https://westus.api.cognitive.microsoft.com' , '--appId' , uuidv1 ( ) , '--name' , 'sample-app' , '--versionId' , '0.1' , '--newVersionId' , '0.2' ] )
35+ . it ( 'displays an error if any required input parameters are missing' , ctx => {
36+ expect ( ctx . stderr ) . to . contain ( `Required input property 'subscriptionKey' missing.` )
37+ } )
38+
39+ test
40+ . nock ( 'https://westus.api.cognitive.microsoft.com' , api => api
41+ . put ( uri => uri . includes ( 'apps' ) )
42+ . reply ( 200 )
43+ )
44+ . stdout ( )
45+ . command ( [ 'luis:version:rename' , '--endpoint' , 'https://westus.api.cognitive.microsoft.com' , '--subscriptionKey' , uuidv1 ( ) , '--appId' , uuidv1 ( ) , '--name' , 'sample-app' , '--versionId' , '0.1' , '--newVersionId' , '0.2' ] )
46+ . it ( 'renames a LUIS application version and displays a success message' , ctx => {
47+ expect ( ctx . stdout ) . to . contain ( 'App version successfully renamed' )
48+ } )
49+
50+ test
51+ . stdout ( )
52+ . stderr ( )
53+ . command ( [ 'luis:version:rename' , '--endpoint' , 'undefined' , '--subscriptionKey' , uuidv1 ( ) , '--appId' , uuidv1 ( ) , '--name' , 'sample-app' , '--versionId' , '0.1' , '--newVersionId' , '0.2' ] )
54+ . it ( 'fails to rename application version and displays an error message if the endpoint is null' , ctx => {
55+ expect ( ctx . stderr ) . to . contain ( 'Access denied due to invalid subscription key or wrong API endpoint.' )
56+ } )
57+
58+ } )
0 commit comments