room: split test_broadcast_presence
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
4ec1aa42b4
commit
919f3cf754
1 changed files with 70 additions and 2 deletions
72
src/room.rs
72
src/room.rs
|
@ -381,7 +381,7 @@ mod tests {
|
|||
};
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_broadcast_presence() {
|
||||
async fn test_broadcast_presence_resync() {
|
||||
let roomjid = BareJid::from_str("room@muc").unwrap();
|
||||
let realjid1 = FullJid::from_str("foo@bar/qxx").unwrap();
|
||||
let participant1 = roomjid.clone().with_resource(String::from("nick1"));
|
||||
|
@ -443,6 +443,29 @@ mod tests {
|
|||
|
||||
room.broadcast_presence(&mut component, &occupant3, &realjid3, BroadcastPresence::Resync).await.unwrap();
|
||||
component.assert();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_broadcast_presence_update() {
|
||||
let roomjid = BareJid::from_str("room@muc").unwrap();
|
||||
let realjid1 = FullJid::from_str("foo@bar/qxx").unwrap();
|
||||
let participant1 = roomjid.clone().with_resource(String::from("nick1"));
|
||||
let realjid2 = FullJid::from_str("qxx@foo/bar").unwrap();
|
||||
let participant2 = roomjid.clone().with_resource(String::from("nick2"));
|
||||
let realjid3 = FullJid::from_str("bar@qxx/foo").unwrap();
|
||||
let participant3 = roomjid.clone().with_resource(String::from("nick3"));
|
||||
|
||||
let mut room = Room::new(roomjid.clone());
|
||||
|
||||
room.occupants = BTreeMap::new();
|
||||
room.occupants.insert(
|
||||
participant1.resource.clone(), Occupant::new(&room, realjid1.clone(), String::from("nick1")),
|
||||
);
|
||||
room.occupants.insert(
|
||||
participant2.resource.clone(), Occupant::new(&room, realjid2.clone(), String::from("nick2")),
|
||||
);
|
||||
let occupant3 = Occupant::new(&room, realjid3.clone(), String::from("nick3"));
|
||||
room.occupants.insert(participant3.resource.clone(), occupant3.clone());
|
||||
|
||||
// BroadcastPresence::Update
|
||||
let mut component = TestComponent::new(vec![]);
|
||||
|
@ -473,6 +496,29 @@ mod tests {
|
|||
|
||||
room.broadcast_presence(&mut component, &occupant3, &realjid3, BroadcastPresence::Update).await.unwrap();
|
||||
component.assert();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_broadcast_presence_join() {
|
||||
let roomjid = BareJid::from_str("room@muc").unwrap();
|
||||
let realjid1 = FullJid::from_str("foo@bar/qxx").unwrap();
|
||||
let participant1 = roomjid.clone().with_resource(String::from("nick1"));
|
||||
let realjid2 = FullJid::from_str("qxx@foo/bar").unwrap();
|
||||
let participant2 = roomjid.clone().with_resource(String::from("nick2"));
|
||||
let realjid3 = FullJid::from_str("bar@qxx/foo").unwrap();
|
||||
let participant3 = roomjid.clone().with_resource(String::from("nick3"));
|
||||
|
||||
let mut room = Room::new(roomjid.clone());
|
||||
|
||||
room.occupants = BTreeMap::new();
|
||||
room.occupants.insert(
|
||||
participant1.resource.clone(), Occupant::new(&room, realjid1.clone(), String::from("nick1")),
|
||||
);
|
||||
room.occupants.insert(
|
||||
participant2.resource.clone(), Occupant::new(&room, realjid2.clone(), String::from("nick2")),
|
||||
);
|
||||
let occupant3 = Occupant::new(&room, realjid3.clone(), String::from("nick3"));
|
||||
room.occupants.insert(participant3.resource.clone(), occupant3.clone());
|
||||
|
||||
// BroadcastPresence::Join
|
||||
let mut component = TestComponent::new(vec![]);
|
||||
|
@ -539,6 +585,29 @@ mod tests {
|
|||
|
||||
room.broadcast_presence(&mut component, &occupant3, &realjid3, BroadcastPresence::Join).await.unwrap();
|
||||
component.assert();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_broadcast_presence_leave() {
|
||||
let roomjid = BareJid::from_str("room@muc").unwrap();
|
||||
let realjid1 = FullJid::from_str("foo@bar/qxx").unwrap();
|
||||
let participant1 = roomjid.clone().with_resource(String::from("nick1"));
|
||||
let realjid2 = FullJid::from_str("qxx@foo/bar").unwrap();
|
||||
let participant2 = roomjid.clone().with_resource(String::from("nick2"));
|
||||
let realjid3 = FullJid::from_str("bar@qxx/foo").unwrap();
|
||||
let participant3 = roomjid.clone().with_resource(String::from("nick3"));
|
||||
|
||||
let mut room = Room::new(roomjid.clone());
|
||||
|
||||
room.occupants = BTreeMap::new();
|
||||
room.occupants.insert(
|
||||
participant1.resource.clone(), Occupant::new(&room, realjid1.clone(), String::from("nick1")),
|
||||
);
|
||||
room.occupants.insert(
|
||||
participant2.resource.clone(), Occupant::new(&room, realjid2.clone(), String::from("nick2")),
|
||||
);
|
||||
let occupant3 = Occupant::new(&room, realjid3.clone(), String::from("nick3"));
|
||||
room.occupants.insert(participant3.resource.clone(), occupant3.clone());
|
||||
|
||||
// BroadcastPresence::Leave
|
||||
let mut component = TestComponent::new(vec![]);
|
||||
|
@ -581,6 +650,5 @@ mod tests {
|
|||
|
||||
room.broadcast_presence(&mut component, &occupant3, &realjid3, BroadcastPresence::Leave).await.unwrap();
|
||||
component.assert();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue