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';
|
2017-06-25 16:24:25 +08:00
|
|
|
import ReactTestUtils from 'react-dom/test-utils';
|
2016-03-05 07:21:06 +08:00
|
|
|
|
2017-07-24 08:32:52 +08:00
|
|
|
import Package from '../../../src/package';
|
2016-03-05 07:21:06 +08:00
|
|
|
import ThemePicker from '../lib/theme-picker';
|
|
|
|
|
|
|
|
const {resourcePath} = NylasEnv.getLoadSettings();
|
2017-07-24 08:32:52 +08:00
|
|
|
const light = new Package(`${resourcePath}/internal_packages/ui-light`);
|
|
|
|
const dark = new Package(`${resourcePath}/internal_packages/ui-dark`);
|
2016-03-05 07:21:06 +08:00
|
|
|
|
2016-05-05 05:03:15 +08:00
|
|
|
describe('ThemePicker', function themePicker() {
|
2016-05-06 13:30:34 +08:00
|
|
|
beforeEach(() => {
|
2017-07-12 06:42:18 +08:00
|
|
|
spyOn(NylasEnv.themes, 'getAvailableThemes').andReturn([light, dark]);
|
2016-03-05 07:21:06 +08:00
|
|
|
spyOn(NylasEnv.themes, 'getActiveTheme').andReturn(light);
|
|
|
|
this.component = ReactTestUtils.renderIntoDocument(<ThemePicker />);
|
|
|
|
});
|
|
|
|
|
2016-05-06 13:30:34 +08:00
|
|
|
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();
|
|
|
|
});
|
|
|
|
});
|