1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- import React from 'react';
- import {mountWithTheme} from 'sentry-test/enzyme';
- import AccountNotifications from 'app/views/settings/account/accountNotifications';
- describe('AccountNotifications', function() {
- const url = '/users/me/notifications/';
- beforeEach(function() {
- MockApiClient.addMockResponse({
- url,
- method: 'GET',
- body: {
- workflowNotifications: 1,
- selfAssignOnResolve: false,
- weeklyReports: true,
- deployNotifications: 3,
- personalActivityNotifications: true,
- subscribeByDefault: true,
- },
- });
- });
- afterEach(function() {
- MockApiClient.clearMockResponses();
- });
- it('renders with values from API', function() {
- const wrapper = mountWithTheme(<AccountNotifications />, TestStubs.routerContext());
- // "Send Me Project Alerts"
- expect(wrapper.find('Switch[name="subscribeByDefault"]').prop('isActive')).toBe(true);
- // "Workflow Notifications"
- expect(
- wrapper.find('Field[id="workflowNotifications"] RadioGroup').prop('value')
- ).toBe(1);
- // "Deploy Notifications"
- expect(wrapper.find('Field[id="deployNotifications"] RadioGroup').prop('value')).toBe(
- 3
- );
- // "Notify Me About my Own Activity"
- expect(
- wrapper.find('Switch[name="personalActivityNotifications"]').prop('isActive')
- ).toBe(true);
- // "Claim Unassigned Issues"
- expect(wrapper.find('Switch[name="selfAssignOnResolve"]').prop('isActive')).toBe(
- false
- );
- });
- it('can change "Deploy Notifications"', function() {
- const wrapper = mountWithTheme(<AccountNotifications />, TestStubs.routerContext());
- const mock = MockApiClient.addMockResponse({
- url,
- method: 'PUT',
- });
- wrapper
- .find('Field[id="deployNotifications"] RadioLineItem')
- .at(2)
- .simulate('click');
- expect(mock).toHaveBeenCalledWith(
- url,
- expect.objectContaining({
- data: {deployNotifications: 4},
- })
- );
- });
- });
|