@@ -15,16 +15,20 @@ limitations under the License.
15
15
*/
16
16
17
17
import React from "react" ;
18
- import { fireEvent , render , RenderResult } from "@testing-library/react" ;
18
+ import { render , RenderResult } from "@testing-library/react" ;
19
19
import { MatrixClient } from "matrix-js-sdk/src/client" ;
20
+ import userEvent from "@testing-library/user-event" ;
20
21
21
22
import NotificationSettingsTab from "../../../../../../src/components/views/settings/tabs/room/NotificationSettingsTab" ;
22
23
import { mkStubRoom , stubClient } from "../../../../../test-utils" ;
23
24
import { MatrixClientPeg } from "../../../../../../src/MatrixClientPeg" ;
25
+ import { EchoChamber } from "../../../../../../src/stores/local-echo/EchoChamber" ;
26
+ import { RoomEchoChamber } from "../../../../../../src/stores/local-echo/RoomEchoChamber" ;
24
27
25
28
describe ( "NotificatinSettingsTab" , ( ) => {
26
29
const roomId = "!room:example.com" ;
27
30
let cli : MatrixClient ;
31
+ let roomProps : RoomEchoChamber ;
28
32
29
33
const renderTab = ( ) : RenderResult => {
30
34
return render ( < NotificationSettingsTab roomId = { roomId } closeSettingsFn = { ( ) => { } } /> ) ;
@@ -33,20 +37,22 @@ describe("NotificatinSettingsTab", () => {
33
37
beforeEach ( ( ) => {
34
38
stubClient ( ) ;
35
39
cli = MatrixClientPeg . get ( ) ;
36
- mkStubRoom ( roomId , "test room" , cli ) ;
40
+ const room = mkStubRoom ( roomId , "test room" , cli ) ;
41
+ roomProps = EchoChamber . forRoom ( room ) ;
37
42
38
43
NotificationSettingsTab . contextType = React . createContext ( cli ) ;
39
44
} ) ;
40
45
41
- it ( "should prevent »Settings« link click from bubbling up to radio buttons" , ( ) => {
46
+ it ( "should prevent »Settings« link click from bubbling up to radio buttons" , async ( ) => {
42
47
const tab = renderTab ( ) ;
43
- const event = new MouseEvent ( "click" , { bubbles : true } ) ;
44
- Object . assign ( event , { preventDefault : jest . fn ( ) } ) ;
45
48
46
- const settingsLink = tab . container . querySelector ( "div.mx_AccessibleButton" ) ;
49
+ // settings link of mentions_only volume
50
+ const settingsLink = tab . container . querySelector (
51
+ "label.mx_NotificationSettingsTab_mentionsKeywordsEntry div.mx_AccessibleButton" ) ;
47
52
if ( ! settingsLink ) throw new Error ( "settings link does not exist." ) ;
48
53
49
- fireEvent ( settingsLink , event ) ;
50
- expect ( event . preventDefault ) . toHaveBeenCalledTimes ( 1 ) ;
54
+ await userEvent . click ( settingsLink ) ;
55
+
56
+ expect ( roomProps . notificationVolume ) . not . toBe ( "mentions_only" ) ;
51
57
} ) ;
52
58
} ) ;
0 commit comments