fix email notification setting on Android (#2065)
This commit is contained in:
parent
4b32918c1f
commit
dbd77b87e0
3 changed files with 60 additions and 16 deletions
|
|
@ -41,10 +41,6 @@ class NotificationSettingsEmailAndroid extends NotificationSettingsEmailBase {
|
|||
this.setState({showEmailNotificationsModal: true});
|
||||
};
|
||||
|
||||
handleChange = (value) => {
|
||||
this.setState({newInterval: value});
|
||||
}
|
||||
|
||||
renderEmailSection() {
|
||||
const {
|
||||
sendEmailNotifications,
|
||||
|
|
@ -183,7 +179,7 @@ class NotificationSettingsEmailAndroid extends NotificationSettingsEmailBase {
|
|||
{sendEmailNotifications &&
|
||||
<RadioButtonGroup
|
||||
name='emailSettings'
|
||||
onSelect={this.handleChange}
|
||||
onSelect={this.setEmailNotifications}
|
||||
options={emailOptions}
|
||||
/>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ configure({adapter: new Adapter()});
|
|||
import {shallowWithIntl} from 'test/intl-test-helper';
|
||||
import {emptyFunction} from 'app/utils/general';
|
||||
|
||||
import RadioButtonGroup from 'app/components/radio_button';
|
||||
|
||||
import NotificationSettingsEmailAndroid from './notification_settings_email.android.js';
|
||||
|
||||
describe('NotificationSettingsEmailAndroid', () => {
|
||||
|
|
@ -68,6 +70,29 @@ describe('NotificationSettingsEmailAndroid', () => {
|
|||
expect(wrapper.state({email: 'true', interval: '3600'}));
|
||||
});
|
||||
|
||||
test('should match state on select of RadioButtonGroup', () => {
|
||||
const wrapper = shallowWithIntl(
|
||||
<NotificationSettingsEmailAndroid
|
||||
{...baseProps}
|
||||
sendEmailNotifications={false}
|
||||
/>
|
||||
);
|
||||
expect(wrapper.find(RadioButtonGroup).exists()).toBe(false);
|
||||
wrapper.setProps({sendEmailNotifications: true});
|
||||
expect(wrapper.find(RadioButtonGroup).exists()).toBe(true);
|
||||
|
||||
wrapper.setState({email: 'false', interval: '0'});
|
||||
|
||||
wrapper.find(RadioButtonGroup).first().prop('onSelect')('30');
|
||||
expect(wrapper.state({email: 'true', interval: '30'}));
|
||||
|
||||
wrapper.find(RadioButtonGroup).first().prop('onSelect')('0');
|
||||
expect(wrapper.state({email: 'false', interval: '0'}));
|
||||
|
||||
wrapper.find(RadioButtonGroup).first().prop('onSelect')('3600');
|
||||
expect(wrapper.state({email: 'true', interval: '3600'}));
|
||||
});
|
||||
|
||||
test('should match state on handleClose', () => {
|
||||
const wrapper = shallowWithIntl(
|
||||
<NotificationSettingsEmailAndroid {...baseProps}/>
|
||||
|
|
@ -118,14 +143,4 @@ describe('NotificationSettingsEmailAndroid', () => {
|
|||
wrapper.instance().showEmailModal();
|
||||
expect(wrapper.state('showEmailNotificationsModal')).toEqual(true);
|
||||
});
|
||||
|
||||
test('should match state on handleChange', () => {
|
||||
const wrapper = shallowWithIntl(
|
||||
<NotificationSettingsEmailAndroid {...baseProps}/>
|
||||
);
|
||||
|
||||
wrapper.setState({newInterval: '3600'});
|
||||
wrapper.instance().handleChange('30');
|
||||
expect(wrapper.state('newInterval')).toEqual('30');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ configure({adapter: new Adapter()});
|
|||
|
||||
import {emptyFunction} from 'app/utils/general';
|
||||
|
||||
import SectionItem from 'app/screens/settings/section_item';
|
||||
|
||||
import NotificationSettingsEmailIos from './notification_settings_email.ios.js';
|
||||
|
||||
jest.mock('app/utils/theme', () => {
|
||||
|
|
@ -74,7 +76,7 @@ describe('NotificationSettingsEmailIos', () => {
|
|||
expect(savePreferences).toBeCalledWith('current_user_id', [{category: 'notifications', name: 'email_interval', user_id: 'current_user_id', value: 30}]);
|
||||
});
|
||||
|
||||
test('should macth state on setEmailNotifications', () => {
|
||||
test('should match state on setEmailNotifications', () => {
|
||||
const wrapper = shallow(
|
||||
<NotificationSettingsEmailIos {...baseProps}/>
|
||||
);
|
||||
|
|
@ -90,6 +92,37 @@ describe('NotificationSettingsEmailIos', () => {
|
|||
expect(wrapper.state({email: 'true', interval: '3600'}));
|
||||
});
|
||||
|
||||
test('should match state on action of SectionItem', () => {
|
||||
const wrapper = shallow(
|
||||
<NotificationSettingsEmailIos
|
||||
{...baseProps}
|
||||
sendEmailNotifications={false}
|
||||
enableEmailBatching={false}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(wrapper.find(SectionItem).exists()).toBe(false);
|
||||
|
||||
wrapper.setProps({sendEmailNotifications: true});
|
||||
expect(wrapper.find(SectionItem).exists()).toBe(true);
|
||||
expect(wrapper.find(SectionItem).length).toBe(2);
|
||||
|
||||
wrapper.setProps({enableEmailBatching: true});
|
||||
expect(wrapper.find(SectionItem).exists()).toBe(true);
|
||||
expect(wrapper.find(SectionItem).length).toBe(4);
|
||||
|
||||
wrapper.setState({email: 'false', interval: '0'});
|
||||
|
||||
wrapper.find(SectionItem).first().prop('action')('30');
|
||||
expect(wrapper.state({email: 'true', interval: '30'}));
|
||||
|
||||
wrapper.find(SectionItem).first().prop('action')('0');
|
||||
expect(wrapper.state({email: 'true', interval: '0'}));
|
||||
|
||||
wrapper.find(SectionItem).last().prop('action')('3600');
|
||||
expect(wrapper.state({email: 'true', interval: '3600'}));
|
||||
});
|
||||
|
||||
test('should call props.actions.savePreferences on saveUserNotifyProps', () => {
|
||||
const props = {...baseProps, actions: {savePreferences: jest.fn(), updateMe: jest.fn()}};
|
||||
const wrapper = shallow(
|
||||
|
|
|
|||
Loading…
Reference in a new issue