2016-03-05 07:21:06 +08:00
|
|
|
import React from 'react';
|
2016-03-29 16:41:24 +08:00
|
|
|
import ReactDOM from 'react-dom';
|
|
|
|
import ReactTestUtils from 'react-addons-test-utils';
|
2016-03-05 07:21:06 +08:00
|
|
|
|
|
|
|
import ThemePackage from '../../../src/theme-package';
|
|
|
|
import ThemePicker from '../lib/theme-picker';
|
|
|
|
|
|
|
|
const {resourcePath} = NylasEnv.getLoadSettings();
|
|
|
|
const light = new ThemePackage(resourcePath + '/internal_packages/ui-light');
|
|
|
|
const dark = new ThemePackage(resourcePath + '/internal_packages/ui-dark');
|
|
|
|
|
2016-05-05 05:03:15 +08:00
|
|
|
describe('ThemePicker', function themePicker() {
|
2016-03-05 07:21:06 +08:00
|
|
|
beforeEach(()=> {
|
2016-03-11 06:10:48 +08:00
|
|
|
spyOn(NylasEnv.themes, 'getLoadedThemes').andReturn([light, dark]);
|
2016-03-05 07:21:06 +08:00
|
|
|
spyOn(NylasEnv.themes, 'getActiveTheme').andReturn(light);
|
|
|
|
this.component = ReactTestUtils.renderIntoDocument(<ThemePicker />);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('changes the active theme when a theme is clicked', ()=> {
|
2016-03-09 09:08:09 +08:00
|
|
|
spyOn(ThemePicker.prototype, '_setActiveTheme').andCallThrough();
|
|
|
|
spyOn(ThemePicker.prototype, '_rewriteIFrame');
|
2016-03-29 16:41:24 +08:00
|
|
|
const themeOption = ReactDOM.findDOMNode(ReactTestUtils.scryRenderedDOMComponentsWithClass(this.component, 'clickable-theme-option')[1]);
|
2016-03-05 07:21:06 +08:00
|
|
|
ReactTestUtils.Simulate.mouseDown(themeOption);
|
|
|
|
expect(ThemePicker.prototype._setActiveTheme).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|