This repository has been archived by the owner on Apr 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #781 from LiskHQ/745-settings-page
Create a settings page - Closes #745
- Loading branch information
Showing
9 changed files
with
106 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Feature: Settings dialog | ||
Scenario: should allow to change language | ||
Given I'm logged in as "any account" | ||
When I click "settings" in main menu | ||
And I select option no. 2 from "language" select | ||
Then I should see text "SENDEN" in "send button" element |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,38 @@ | ||
import { Dropdown } from 'react-toolbox'; | ||
import { translate } from 'react-i18next'; | ||
import React from 'react'; | ||
|
||
import i18n from '../../i18n'; | ||
import languages from '../../constants/languages'; | ||
|
||
const languagesSource = Object.keys(languages).map(key => ({ | ||
value: key, | ||
label: languages[key].name, | ||
flag: languages[key].flag, | ||
})); | ||
|
||
const handleChange = (value) => { | ||
i18n.changeLanguage(value); | ||
}; | ||
|
||
const customItem = item => ( | ||
<div> | ||
<img src={item.flag}/> {item.label} | ||
</div> | ||
); | ||
|
||
const Settings = ({ t }) => ( | ||
<form> | ||
<Dropdown | ||
auto={false} | ||
className='language' | ||
label={t('Language')} | ||
source={languagesSource} | ||
value={i18n.language} | ||
template={customItem} | ||
onChange={handleChange} | ||
/> | ||
</form> | ||
); | ||
|
||
export default translate()(Settings); |
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,42 @@ | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
|
||
import { expect } from 'chai'; | ||
import { mount } from 'enzyme'; | ||
import sinon from 'sinon'; | ||
|
||
import Settings from './index'; | ||
import i18n from '../../i18n'; | ||
|
||
// import * as accountApi from '../../utils/api/account'; | ||
|
||
|
||
describe('Settings', () => { | ||
let wrapper; | ||
let props; | ||
|
||
beforeEach(() => { | ||
props = { | ||
}; | ||
wrapper = mount(<Settings {...props} />, { | ||
context: { i18n }, | ||
childContextTypes: { | ||
i18n: PropTypes.object.isRequired, | ||
}, | ||
}); | ||
}); | ||
|
||
it('renders a form and a Dropdown components', () => { | ||
expect(wrapper.find('Dropdown')).to.have.length(1); | ||
}); | ||
|
||
it('calls i18n.changeLanguage on chaning the value in the dropdown', () => { | ||
const i18nSpy = sinon.spy(i18n, 'changeLanguage'); | ||
|
||
wrapper.find('Dropdown').simulate('click'); | ||
wrapper.find('Dropdown ul li').at(0).simulate('click'); | ||
expect(i18nSpy).to.have.been.calledWith('en'); | ||
|
||
i18nSpy.restore(); | ||
}); | ||
}); |
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