This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
don't set api password or port to undefined
- Loading branch information
1 parent
e6da924
commit de04589
Showing
3 changed files
with
84 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { getCoreAPIPasswordFromURL, getLogServerPortFromURL } from '../../app/js/utils/api-utils' | ||
|
||
describe('api-utils', () => { | ||
beforeEach(() => { | ||
global.origWindow = global.window | ||
global.window = { // mock window for hash-handler | ||
location: { | ||
hash: '#' | ||
}, | ||
addEventListener: () => { | ||
// do nothing | ||
} | ||
} | ||
}) | ||
|
||
afterEach(() => { | ||
global.window = global.origWindow | ||
}) | ||
describe('getCoreAPIPasswordFromURL()', () => { | ||
it('should return the password', () => { | ||
const hash = '#coreAPIPassword=abc123&logServerPort=8333' | ||
window.location.hash = hash | ||
assert.equal(window.location.hash, '#coreAPIPassword=abc123&logServerPort=8333') | ||
assert.equal(getCoreAPIPasswordFromURL(), 'abc123') | ||
}) | ||
|
||
it('should be null if password is off', () => { | ||
const hash = '#coreAPIPassword=off' | ||
window.location.hash = hash | ||
assert.equal(getCoreAPIPasswordFromURL(), null) | ||
}) | ||
|
||
it('should be null if password parameter does not exist', () => { | ||
const hash = '' | ||
window.location.hash = hash | ||
assert.equal(getCoreAPIPasswordFromURL(), null) | ||
}) | ||
}) | ||
|
||
describe('getLogServerPortFromURL()', () => { | ||
it('should return the port', () => { | ||
const hash = '#coreAPIPassword=abc123&logServerPort=8333' | ||
window.location.hash = hash | ||
assert.equal(window.location.hash, '#coreAPIPassword=abc123&logServerPort=8333') | ||
assert.equal(getLogServerPortFromURL(), '8333') | ||
}) | ||
|
||
it('should be null if port is off', () => { | ||
const hash = '#logServerPort=off' | ||
window.location.hash = hash | ||
assert.equal(getLogServerPortFromURL(), null) | ||
}) | ||
|
||
it('should be null if port parameter does not exist', () => { | ||
const hash = '' | ||
window.location.hash = hash | ||
assert.equal(getLogServerPortFromURL(), null) | ||
}) | ||
}) | ||
}) |