@@ -18,29 +18,29 @@ describe('Namespace', function() {
1818 it ( 'should change public app relevant variables in Backendless scope' , ( ) => {
1919 Backendless . initApp ( APP_ID , API_KEY )
2020
21- expect ( Backendless . applicationId ) . to . be . equal ( APP_ID )
22- expect ( Backendless . secretKey ) . to . be . equal ( API_KEY )
21+ expect ( Backendless . appId ) . to . be . equal ( APP_ID )
22+ expect ( Backendless . apiKey ) . to . be . equal ( API_KEY )
2323 } )
2424
2525 it ( 'should change public app relevant variables in Backendless scope using object config' , ( ) => {
2626 Backendless . initApp ( { appId : APP_ID , apiKey : API_KEY } )
2727
28- expect ( Backendless . applicationId ) . to . be . equal ( APP_ID )
29- expect ( Backendless . secretKey ) . to . be . equal ( API_KEY )
28+ expect ( Backendless . appId ) . to . be . equal ( APP_ID )
29+ expect ( Backendless . apiKey ) . to . be . equal ( API_KEY )
3030 } )
3131
3232 it ( 'should not change public variables in Backendless scope' , ( ) => {
3333 Backendless . serverURL = 'http://foo.bar'
3434 Backendless . initApp ( APP_ID , API_KEY )
3535
36- expect ( ( ) => Backendless . applicationId = 'applicationId ' ) . to . throw ( )
37- expect ( ( ) => Backendless . secretKey = 'secretKey ' ) . to . throw ( )
36+ expect ( ( ) => Backendless . appId = 'appId ' ) . to . throw ( )
37+ expect ( ( ) => Backendless . apiKey = 'apiKey ' ) . to . throw ( )
3838 expect ( ( ) => Backendless . appPath = 'appPath' ) . to . throw ( )
3939 expect ( ( ) => Backendless . standalone = 'standalone' ) . to . throw ( )
4040 expect ( ( ) => Backendless . device = 'device' ) . to . throw ( )
4141
42- expect ( Backendless . applicationId ) . to . be . equal ( APP_ID )
43- expect ( Backendless . secretKey ) . to . be . equal ( API_KEY )
42+ expect ( Backendless . appId ) . to . be . equal ( APP_ID )
43+ expect ( Backendless . apiKey ) . to . be . equal ( API_KEY )
4444 expect ( Backendless . appPath ) . to . be . equal ( `http://foo.bar/${ APP_ID } /${ API_KEY } ` )
4545 } )
4646 } )
@@ -51,11 +51,11 @@ describe('Namespace', function() {
5151 const app2 = Backendless . initApp ( { appId : 'appId-2' , apiKey : 'apiKey-2' , standalone : true } )
5252 const app3 = Backendless . initApp ( { appId : 'appId-3' , apiKey : 'apiKey-3' , standalone : true } )
5353
54- expect ( app2 . applicationId ) . to . be . equal ( 'appId-2' )
55- expect ( app2 . secretKey ) . to . be . equal ( 'apiKey-2' )
54+ expect ( app2 . appId ) . to . be . equal ( 'appId-2' )
55+ expect ( app2 . apiKey ) . to . be . equal ( 'apiKey-2' )
5656
57- expect ( app3 . applicationId ) . to . be . equal ( 'appId-3' )
58- expect ( app3 . secretKey ) . to . be . equal ( 'apiKey-3' )
57+ expect ( app3 . appId ) . to . be . equal ( 'appId-3' )
58+ expect ( app3 . apiKey ) . to . be . equal ( 'apiKey-3' )
5959 } )
6060
6161 it ( 'has custom serverURL' , ( ) => {
@@ -66,8 +66,8 @@ describe('Namespace', function() {
6666 standalone : true
6767 } )
6868
69- expect ( app1 . applicationId ) . to . be . equal ( 'appId-1' )
70- expect ( app1 . secretKey ) . to . be . equal ( 'apiKey-1' )
69+ expect ( app1 . appId ) . to . be . equal ( 'appId-1' )
70+ expect ( app1 . apiKey ) . to . be . equal ( 'apiKey-1' )
7171 expect ( app1 . appPath ) . to . be . equal ( 'http://my-server-url.com/appId-1/apiKey-1' )
7272 } )
7373 } )
@@ -77,18 +77,18 @@ describe('Namespace', function() {
7777 it ( 'should init with custom domain' , ( ) => {
7878 Backendless . initApp ( CUSTOM_DOMAIN )
7979
80- expect ( Backendless . applicationId ) . to . be . equal ( null )
81- expect ( Backendless . secretKey ) . to . be . equal ( null )
80+ expect ( Backendless . appId ) . to . be . equal ( null )
81+ expect ( Backendless . apiKey ) . to . be . equal ( null )
8282 expect ( Backendless . domain ) . to . be . equal ( CUSTOM_DOMAIN )
8383 expect ( Backendless . appPath ) . to . be . equal ( `${ CUSTOM_DOMAIN } /api` )
8484 expect ( Backendless . apiURI ) . to . be . equal ( '/api' )
8585 } )
8686
8787 it ( 'should init with custom domain via config object' , ( ) => {
88- Backendless . initApp ( { domain : CUSTOM_DOMAIN , secretKey : 'XXX' } )
88+ Backendless . initApp ( { domain : CUSTOM_DOMAIN , apiKey : 'XXX' } )
8989
90- expect ( Backendless . applicationId ) . to . be . equal ( null )
91- expect ( Backendless . secretKey ) . to . be . equal ( null )
90+ expect ( Backendless . appId ) . to . be . equal ( null )
91+ expect ( Backendless . apiKey ) . to . be . equal ( null )
9292 expect ( Backendless . domain ) . to . be . equal ( CUSTOM_DOMAIN )
9393 expect ( Backendless . appPath ) . to . be . equal ( `${ CUSTOM_DOMAIN } /api` )
9494 expect ( Backendless . apiURI ) . to . be . equal ( '/api' )
@@ -101,6 +101,8 @@ describe('Namespace', function() {
101101 expect ( Backendless . domain ) . to . be . equal ( CUSTOM_DOMAIN )
102102 expect ( Backendless . appPath ) . to . be . equal ( `${ CUSTOM_DOMAIN } /my-api-uri` )
103103 expect ( Backendless . apiURI ) . to . be . equal ( '/my-api-uri' )
104+
105+ Backendless . apiURI = undefined
104106 } )
105107
106108 it ( 'should fails with custom domain which does not start on https or http' , ( ) => {
@@ -351,5 +353,41 @@ describe('Namespace', function() {
351353 expect ( global . Backendless ) . to . equal ( undefined )
352354 } )
353355
356+ it ( 'should support deprecated applicationId and secretKey' , function ( ) {
357+ Backendless . initApp ( APP_ID , API_KEY )
358+
359+ // eslint-disable-next-line no-console
360+ const _nativeConsoleWarn = console . warn
361+
362+ // eslint-disable-next-line no-console
363+ const spyConsoleWarn = console . warn = chai . spy ( )
364+
365+ expect ( Backendless . applicationId ) . to . be . equal ( APP_ID )
366+ expect ( Backendless . secretKey ) . to . be . equal ( API_KEY )
367+ expect ( ( ) => Backendless . applicationId = 'applicationId' ) . to . throw ( '' ) // eslint-disable-line
368+ expect ( ( ) => Backendless . secretKey = 'secretKey' ) . to . throw ( '' ) // eslint-disable-line
369+
370+ Backendless . initApp ( { domain : 'https://foo.com' , apiKey : 'XXX' } )
371+
372+ expect ( Backendless . appId ) . to . be . equal ( null )
373+ expect ( Backendless . apiKey ) . to . be . equal ( null )
374+ expect ( Backendless . domain ) . to . be . equal ( 'https://foo.com' )
375+ expect ( Backendless . appPath ) . to . be . equal ( 'https://foo.com/api' )
376+ expect ( Backendless . apiURI ) . to . be . equal ( '/api' )
377+
378+ const appIdWarnMsg = 'getter/setter for Backendless.applicationId is deprecated, instead use Backendless.appId'
379+ const apiKeyWarnMsg = 'getter/setter for Backendless.secretKey is deprecated, instead use Backendless.apiKey'
380+
381+ expect ( spyConsoleWarn ) . to . have . been . called . exactly ( 4 )
382+
383+ expect ( spyConsoleWarn ) . on . nth ( 1 ) . be . called . with ( appIdWarnMsg )
384+ expect ( spyConsoleWarn ) . on . nth ( 2 ) . be . called . with ( apiKeyWarnMsg )
385+ expect ( spyConsoleWarn ) . on . nth ( 3 ) . be . called . with ( appIdWarnMsg )
386+ expect ( spyConsoleWarn ) . on . nth ( 4 ) . be . called . with ( apiKeyWarnMsg )
387+
388+ // eslint-disable-next-line no-console
389+ console . warn = _nativeConsoleWarn
390+ } )
391+
354392 } )
355393} )
0 commit comments