diff --git a/app/screens/settings/notification_settings_email/notification_settings_email.android.js b/app/screens/settings/notification_settings_email/notification_settings_email.android.js index 3d01850bb..af1072344 100644 --- a/app/screens/settings/notification_settings_email/notification_settings_email.android.js +++ b/app/screens/settings/notification_settings_email/notification_settings_email.android.js @@ -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 && } diff --git a/app/screens/settings/notification_settings_email/notification_settings_email.android.test.js b/app/screens/settings/notification_settings_email/notification_settings_email.android.test.js index 99667b6cb..8649e6fda 100644 --- a/app/screens/settings/notification_settings_email/notification_settings_email.android.test.js +++ b/app/screens/settings/notification_settings_email/notification_settings_email.android.test.js @@ -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( + + ); + 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( @@ -118,14 +143,4 @@ describe('NotificationSettingsEmailAndroid', () => { wrapper.instance().showEmailModal(); expect(wrapper.state('showEmailNotificationsModal')).toEqual(true); }); - - test('should match state on handleChange', () => { - const wrapper = shallowWithIntl( - - ); - - wrapper.setState({newInterval: '3600'}); - wrapper.instance().handleChange('30'); - expect(wrapper.state('newInterval')).toEqual('30'); - }); }); diff --git a/app/screens/settings/notification_settings_email/notification_settings_email.ios.test.js b/app/screens/settings/notification_settings_email/notification_settings_email.ios.test.js index 5cac49efd..d2d5fb586 100644 --- a/app/screens/settings/notification_settings_email/notification_settings_email.ios.test.js +++ b/app/screens/settings/notification_settings_email/notification_settings_email.ios.test.js @@ -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( ); @@ -90,6 +92,37 @@ describe('NotificationSettingsEmailIos', () => { expect(wrapper.state({email: 'true', interval: '3600'})); }); + test('should match state on action of SectionItem', () => { + const wrapper = shallow( + + ); + + 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(