Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Implement push notification toggle in device detail #9308

Merged
merged 19 commits into from
Sep 27, 2022
Merged
Prev Previous commit
Next Next commit
add test for pusher enabled
  • Loading branch information
Germain Souquet committed Sep 27, 2022
commit 45ee44fe61c2fba11f3d1948991c9954635e0bb0
27 changes: 26 additions & 1 deletion test/components/views/settings/devices/DeviceDetails-test.tsx
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ limitations under the License.
*/

import React from 'react';
import { render } from '@testing-library/react';
import { fireEvent, render } from '@testing-library/react';
import { IPusher } from 'matrix-js-sdk/src/@types/PushRules';
import { PUSHER_ENABLED } from 'matrix-js-sdk/src/@types/event';

@@ -145,4 +145,29 @@ describe('<DeviceDetails />', () => {
expect(checkbox.getAttribute('aria-disabled')).toEqual("true");
expect(checkbox.getAttribute('aria-checked')).toEqual("false");
});

it('changes the pusher status when clicked', () => {
const device = {
...baseDevice,
};

const enabled = false;

const pusher = mkPusher({
device_id: device.device_id,
[PUSHER_ENABLED.name]: enabled,
});

const { getByTestId } = render(getComponent({
device,
pusher,
isSigningOut: true,
}));

const checkbox = getByTestId('device-detail-push-notification-checkbox');

fireEvent.click(checkbox);

expect(defaultProps.setPusherEnabled).toHaveBeenCalledWith(!enabled);
});
});