@@ -14,60 +14,55 @@ describe('Teams API Test', () => {
1414 const user = jsonReader ( 'loggedinuser.json' )
1515 client = contentstackClient ( user . authtoken )
1616 } )
17- it ( 'should fetch all stackRoleMappings' , async ( ) => {
18- try {
19- makestackRoleMappings ( organizationUid , teamUid ) . fetchAll ( ) . then ( ( response ) => {
20- console . log ( '🚀 ~ file: team-stack-role-mapping-test.js:19 ~ makestackRoleMappings ~ response:' , response . stackRoleMappings [ 0 ] . roles )
17+ it ( 'should fetch all stackRoleMappings' , done => {
18+ makestackRoleMappings ( organizationUid , teamUid ) . fetchAll ( ) . then ( ( response ) => {
19+ response . items . forEach ( ( stackRoleMapping ) => {
20+ console . log ( stackRoleMapping )
2121 } )
22- } catch ( err ) {
23- console . log ( "🚀 ~ file: team-stack-role-mapping-test.js:21 ~ it.only ~ err:" , err )
24- }
22+ expect ( response ) . to . be . not . equal ( null )
23+ done ( )
24+ } )
25+ . catch ( done )
2526 } )
26- it ( 'should add roles' , async ( ) => {
27- try {
28- const stackRoleMappings = {
29- stackApiKey : 'stackApiKey' ,
30- roles : [
31- 'role_uid'
32- ]
33- }
34- await makestackRoleMappings ( organizationUid , teamUid ) . add ( stackRoleMappings ) . then ( ( response ) => {
35- console . log ( '🚀 ~ file: team-stack-role-mapping-test.js:36 ~ awaitmakestackRoleMappings ~ response:' , response )
36- } )
37- } catch ( err ) {
38- console . log ( err )
27+ it ( 'should add roles' , done => {
28+ const stackRoleMappings = {
29+ stackApiKey : 'stackApiKey' ,
30+ roles : [
31+ 'role_uid'
32+ ]
3933 }
34+ makestackRoleMappings ( organizationUid , teamUid ) . add ( stackRoleMappings ) . then ( ( response ) => {
35+ expect ( response . stackRoleMapping ) . not . to . be . equal ( undefined )
36+ expect ( response . stackRoleMapping . roles [ 0 ] ) . to . be . equal ( stackRoleMappings . roles [ 0 ] )
37+ expect ( response . stackRoleMapping . stackApiKey ) . to . be . equal ( stackRoleMappings . stackApiKey )
38+ done ( )
39+ } )
40+ . catch ( done )
4041 } )
41- it ( 'should update roles' , async ( ) => {
42- try {
43- const stackRoleMappings = {
44- roles : [
45- 'role_uid1' ,
46- 'role_uid2'
47- ]
48- }
49- await makestackRoleMappings ( organizationUid , teamUid , stackApiKey ) . update ( stackRoleMappings ) . then ( ( response ) => {
50- console . log ( '🚀 ~ file: team-stack-role-mapping-test.js:31 ~ makestackRoleMappings ~ response:' , response )
51- } )
52- } catch ( err ) {
53- console . log ( err . errors )
42+ it ( 'should update roles' , done => {
43+ const stackRoleMappings = {
44+ roles : [
45+ 'role_uid1' ,
46+ 'role_uid2'
47+ ]
5448 }
49+ makestackRoleMappings ( organizationUid , teamUid , stackApiKey ) . update ( stackRoleMappings ) . then ( ( response ) => {
50+ expect ( response . stackRoleMapping ) . not . to . be . equal ( undefined )
51+ expect ( response . stackRoleMapping . roles [ 0 ] ) . to . be . equal ( stackRoleMappings . roles [ 0 ] )
52+ expect ( response . stackRoleMapping . stackApiKey ) . to . be . equal ( stackApiKey )
53+ done ( )
54+ } )
55+ . catch ( done )
5556 } )
56- it ( 'should delete roles' , async ( ) => {
57- try {
58- await makestackRoleMappings ( organizationUid , teamUid , stackApiKey ) . delete ( ) . then ( ( response ) => {
59- console . log ( '🚀 ~ file: team-stack-role-mapping-test.js:31 ~ makestackRoleMappings ~ response:' , response )
60- } )
61- } catch ( err ) {
62- console . log ( err . errors )
63- }
57+ it ( 'should delete roles' , done => {
58+ makestackRoleMappings ( organizationUid , teamUid , stackApiKey ) . delete ( ) . then ( ( response ) => {
59+ expect ( response . status ) . to . be . equal ( 204 )
60+ done ( )
61+ } )
62+ . catch ( done )
6463 } )
6564} )
6665
6766function makestackRoleMappings ( organizationUid , teamUid , stackApiKey = null ) {
6867 return client . organization ( organizationUid ) . teams ( teamUid ) . stackRoleMappings ( stackApiKey )
6968}
70-
71- // delete done
72- // update done
73- // add done
0 commit comments