Skip to content

Commit 05ea9e1

Browse files
committed
refactor: (Core) Bundle
- fix main bundle
1 parent db5197e commit 05ea9e1

File tree

3 files changed

+33
-16
lines changed

3 files changed

+33
-16
lines changed

src/index.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ import LocalVars from './local-vars'
1919
import { initApp } from './init-app'
2020
import { getUserAgent } from './user-agent'
2121
import { 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

2428
const 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

src/no-conflct.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

test/e2e/specs/init-app.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,27 @@ const SECRET_KEY = 'ACC8DAE2-6402-EBE8-FF74-64439E5D3300'
77
const Backendless = sandbox.Backendless
88

99
describe('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
})

0 commit comments

Comments
 (0)