@@ -191,6 +191,52 @@ - (void)testLeave
191191 }];
192192}
193193
194+ - (void )testIgnoreInviteSender
195+ {
196+ [matrixSDKTestsData doMXRestClientTestWithBobAndARoom: self readyToTest: ^(MXRestClient *bobClient, NSString *roomId, XCTestExpectation *expectation) {
197+
198+ [matrixSDKTestsData doMXRestClientTestWithAlice: nil readyToTest: ^(MXRestClient *aliceClient, XCTestExpectation *expectation2) {
199+
200+ MXSession *mxSession = [[MXSession alloc ] initWithMatrixRestClient: aliceClient];
201+ [matrixSDKTestsData retain: mxSession];
202+
203+ [bobClient inviteUser: aliceClient.credentials.userId toRoom: roomId success: ^{
204+ [mxSession startWithSyncFilter: [MXFilterJSONModel syncFilterWithMessageLimit: 0 ]
205+ onServerSyncDone: ^{
206+
207+ MXRoom *room = [mxSession roomWithRoomId: roomId];
208+ XCTAssertEqual (mxSession.ignoredUsers .count , 0 );
209+ XCTAssertEqual ([mxSession isUserIgnored: bobClient.credentials.userId], NO );
210+
211+ // Listen to mxSession.ignoredUsers changes where the successful assertion happens
212+ [[NSNotificationCenter defaultCenter ] addObserverForName: kMXSessionIgnoredUsersDidChangeNotification object: nil queue: [NSOperationQueue mainQueue ] usingBlock: ^(NSNotification * _Nonnull notif) {
213+ if (notif.object == mxSession)
214+ {
215+ XCTAssertEqual (mxSession.ignoredUsers .count , 1 );
216+ XCTAssertEqual ([mxSession isUserIgnored: bobClient.credentials.userId], YES );
217+
218+ [expectation fulfill ];
219+ }
220+ }];
221+
222+ [room ignoreInviteSender: nil failure: ^(NSError *error) {
223+ XCTFail (@" Failed to ignore invite sender - NSError: %@ " , error);
224+ [expectation fulfill ];
225+ }];
226+
227+ } failure: ^(NSError *error) {;
228+ XCTFail (@" Cannot set up intial test conditions - error: %@ " , error);
229+ [expectation fulfill ];
230+ }];
231+
232+ } failure: ^(NSError *error) {
233+ XCTFail (@" Cannot set up intial test conditions - error: %@ " , error);
234+ [expectation fulfill ];
235+ }];
236+ }];
237+ }];
238+ }
239+
194240- (void )testJoin
195241{
196242 [matrixSDKTestsData doMXRestClientTestWithBobAndARoom: self readyToTest: ^(MXRestClient *bobRestClient, NSString *roomId, XCTestExpectation *expectation) {
0 commit comments