Browse Source

Reload styles when reload button is clicked (#3752)

tags/v4.7.1
reduckted 9 months ago
committed by Jesse Ostrander
parent
commit
cc6ebad51b
2 changed files with 26 additions and 1 deletions
  1. +11
    -1
      src/renderer/ui/components/settings/tabs/StyleTab.js
  2. +15
    -0
      test/electron-renderer/ui/tabs/StyleTab_spec.js

+ 11
- 1
src/renderer/ui/components/settings/tabs/StyleTab.js View File

@@ -4,6 +4,11 @@ import FileInput from '../FileInput';
import SettingsTabWrapper from './SettingsTabWrapper';
import RaisedButton from 'material-ui/RaisedButton';

function refresh() {
Emitter.fire('FetchGPMCustomStyles');
Emitter.fire('FetchMainAppCustomStyles');
}

export default class StyleTab extends Component {
render() {
return (
@@ -18,7 +23,12 @@ export default class StyleTab extends Component {
settingsKey={'gpmStyleFile'}
bonusEvents={['FetchGPMCustomStyles']}
/>
<RaisedButton label={TranslationProvider.query('settings-options-style-refresh')} primary style={{ marginTop: 18 }} />
<RaisedButton
label={TranslationProvider.query('settings-options-style-refresh')}
primary
style={{ marginTop: 18 }}
onClick={refresh}
/>
</SettingsTabWrapper>
);
}


+ 15
- 0
test/electron-renderer/ui/tabs/StyleTab_spec.js View File

@@ -6,12 +6,27 @@ import { mount } from 'enzyme';

import StyleTab from '../../../../build/renderer/ui/components/settings/tabs/StyleTab';
import materialUIContext from '../_materialUIContext';
import mockSettings, { getVars } from '../_mockSettings';

chai.should();

describe('<StyleTab />', () => {
beforeEach(() => {
mockSettings();
});

it('should render a SettingsTabWrapper', () => {
const component = mount(<StyleTab />, materialUIContext);
component.find('SettingsTabWrapper').length.should.be.equal(1);
});

it('should refresh the styles when the refresh button is clicked', () => {
const component = mount(<StyleTab />, materialUIContext);
const buttons = component.find('RaisedButton');
buttons.last().props().onClick();

const fired = getVars().fired;
fired.should.haveOwnProperty('FetchGPMCustomStyles');
fired.should.haveOwnProperty('FetchMainAppCustomStyles');
});
});

Loading…
Cancel
Save