Mailspring/packages/client-app/internal_packages/theme-picker/spec/theme-picker-spec.jsx

27 lines
1.1 KiB
React
Raw Normal View History

import React from 'react';
import ReactDOM from 'react-dom';
import ReactTestUtils from 'react-addons-test-utils';
import ThemePackage from '../../../src/theme-package';
import ThemePicker from '../lib/theme-picker';
const {resourcePath} = NylasEnv.getLoadSettings();
2016-05-07 07:23:48 +08:00
const light = new ThemePackage(`${resourcePath}/internal_packages/ui-light`);
const dark = new ThemePackage(`${resourcePath}/internal_packages/ui-dark`);
describe('ThemePicker', function themePicker() {
2016-05-06 13:30:34 +08:00
beforeEach(() => {
spyOn(NylasEnv.themes, 'getLoadedThemes').andReturn([light, dark]);
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', () => {
spyOn(ThemePicker.prototype, '_setActiveTheme').andCallThrough();
spyOn(ThemePicker.prototype, '_rewriteIFrame');
const themeOption = ReactDOM.findDOMNode(ReactTestUtils.scryRenderedDOMComponentsWithClass(this.component, 'clickable-theme-option')[1]);
ReactTestUtils.Simulate.mouseDown(themeOption);
expect(ThemePicker.prototype._setActiveTheme).toHaveBeenCalled();
});
});