-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #33 by adding the missing 'Basic'
- Loading branch information
Showing
6 changed files
with
57 additions
and
50 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,43 +1,50 @@ | ||
import { ButtonPanel } from './ButtonPanel'; | ||
import { ButtonPanelOptions } from './types'; | ||
|
||
class TestProps { | ||
options: ButtonPanelOptions = { | ||
url: '', | ||
type: 'header', | ||
contentType: '', | ||
isAuth: false, | ||
params: [], | ||
text: '', | ||
variant: 'primary', | ||
orientation: '', | ||
}; | ||
} | ||
|
||
describe('ButtonPanel', () => { | ||
|
||
let underTest : ButtonPanel; | ||
let props: any; | ||
|
||
beforeEach(() => { | ||
let options : ButtonPanelOptions = { | ||
url: '', | ||
type: '', | ||
contentType: '', | ||
isAuth: false, | ||
params: [], | ||
text: '', | ||
variant: 'primary', | ||
orientation: '', | ||
|
||
}; | ||
props = { | ||
options | ||
}; | ||
underTest = new ButtonPanel(props); | ||
}); | ||
|
||
it('should set a proper orientation', () => { | ||
|
||
expect(underTest.getOrientation()).toBe('center'); | ||
|
||
props.options.orientation = 'left'; | ||
expect(underTest.getOrientation()).toBe('left'); | ||
|
||
props.options.orientation = 'right'; | ||
expect(underTest.getOrientation()).toBe('right'); | ||
|
||
props.options.orientation = 'center'; | ||
expect(underTest.getOrientation()).toBe('center'); | ||
|
||
}); | ||
let underTest: ButtonPanel; | ||
let props = new TestProps(); | ||
|
||
beforeEach(() => { | ||
props = new TestProps(); | ||
underTest = new ButtonPanel(props); | ||
}); | ||
|
||
it('should set a proper orientation', () => { | ||
expect(underTest.getOrientation()).toBe('center'); | ||
|
||
props.options.orientation = 'left'; | ||
expect(underTest.getOrientation()).toBe('left'); | ||
|
||
props.options.orientation = 'right'; | ||
expect(underTest.getOrientation()).toBe('right'); | ||
|
||
props.options.orientation = 'center'; | ||
expect(underTest.getOrientation()).toBe('center'); | ||
}); | ||
|
||
it('should send a proper basic auth header', () => { | ||
let url = new URL('http://example.com'); | ||
|
||
props.options.isAuth = true; | ||
props.options.username = 'username'; | ||
props.options.password = 'password'; | ||
|
||
let actual = underTest.prepareFetchOpts(url); | ||
expect(actual).toBeDefined(); | ||
expect((actual.headers as Headers).get('authorization')).toBe('Basic dXNlcm5hbWU6cGFzc3dvcmQ='); | ||
}); | ||
}); |
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