File tree Expand file tree Collapse file tree 3 files changed +33
-16
lines changed
Expand file tree Collapse file tree 3 files changed +33
-16
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,11 @@ import LocalVars from './local-vars'
1919import { initApp } from './init-app'
2020import { getUserAgent } from './user-agent'
2121import { getCurrentUserToken } from './users/current-user'
22- import { noConflict } from './no-conflct'
22+
23+ const root = ( typeof self === 'object' && self . self === self && self ) ||
24+ ( typeof global === 'object' && global . global === global && global )
25+
26+ const previousBackendless = root && root . Backendless
2327
2428const Backendless = {
2529
@@ -60,13 +64,23 @@ const Backendless = {
6064 } ,
6165
6266 initApp,
63- noConflict ,
67+
6468 getCurrentUserToken,
69+
6570 setupDevice : Device . setup ,
71+
6672 browser : getUserAgent ( ) ,
6773
6874 Request,
6975
76+ noConflict ( ) {
77+ if ( root ) {
78+ root . Backendless = previousBackendless
79+ }
80+
81+ return Backendless
82+ } ,
83+
7084 ///-------------------------------------///
7185 ///-------------- SERVICES -------------///
7286
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -7,10 +7,27 @@ const SECRET_KEY = 'ACC8DAE2-6402-EBE8-FF74-64439E5D3300'
77const Backendless = sandbox . Backendless
88
99describe ( 'initApp' , function ( ) {
10+
11+ sandbox . forSuite ( )
12+
1013 it ( 'should change public app relevant variables in Backendless scope' , function ( ) {
1114 Backendless . initApp ( APP_ID , SECRET_KEY )
1215
1316 expect ( Backendless . applicationId ) . to . be . equal ( APP_ID )
1417 expect ( Backendless . secretKey ) . to . be . equal ( SECRET_KEY )
1518 } )
19+
20+ it ( 'should not public variables in Backendless scope' , function ( ) {
21+ Backendless . initApp ( APP_ID , SECRET_KEY )
22+
23+ const appPath = Backendless . appPath
24+
25+ expect ( ( ) => Backendless . applicationId = 'applicationId' ) . to . throwError
26+ expect ( ( ) => Backendless . secretKey = 'secretKey' ) . to . throwError
27+ expect ( ( ) => Backendless . appPath = 'appPath' ) . to . throwError
28+
29+ expect ( Backendless . applicationId ) . to . be . equal ( APP_ID )
30+ expect ( Backendless . secretKey ) . to . be . equal ( SECRET_KEY )
31+ expect ( Backendless . appPath ) . to . be . equal ( appPath )
32+ } )
1633} )
You can’t perform that action at this time.
0 commit comments