Tests: neutral sample account names in the profile fixtures
This commit is contained in:
parent
af631fd1f8
commit
0e344ee119
1 changed files with 8 additions and 8 deletions
|
|
@ -241,19 +241,19 @@ mod tests {
|
|||
}
|
||||
|
||||
fn account(handle: &str) -> Account {
|
||||
Account { handle: handle.into(), name: "Fishies".into(), avatar: Some("https://pbs.twimg.com/profile_images/1/a_normal.jpg".into()), signed_in: false }
|
||||
Account { handle: handle.into(), name: "Sample".into(), avatar: Some("https://pbs.twimg.com/profile_images/1/a_normal.jpg".into()), signed_in: false }
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_seen_login_names_the_profile_and_persists_a_sign_out() {
|
||||
let mut settings = ProfileSettings { profiles: vec![profile("default"), profile("p1")], active: "default".into() };
|
||||
assert!(settings.observe("p1", AccountSeen::SignedIn(account("@playfishies")), RULES));
|
||||
assert!(settings.observe("p1", AccountSeen::SignedIn(account("@otheraccount")), RULES));
|
||||
let seen = settings.profiles[1].account.clone().unwrap();
|
||||
assert_eq!((seen.handle.as_str(), seen.signed_in, settings.profiles[1].name.as_str()), ("playfishies", true, "Fishies"));
|
||||
assert_eq!((seen.handle.as_str(), seen.signed_in, settings.profiles[1].name.as_str()), ("otheraccount", true, "Sample"));
|
||||
// The same report again changes nothing (no disk write).
|
||||
assert!(!settings.observe("p1", AccountSeen::SignedIn(account("playfishies")), RULES));
|
||||
assert!(!settings.observe("p1", AccountSeen::SignedIn(account("otheraccount")), RULES));
|
||||
assert!(settings.observe("p1", AccountSeen::SignedOut, RULES));
|
||||
assert_eq!(settings.profiles[1].account.as_ref().map(|a| (a.handle.as_str(), a.signed_in)), Some(("playfishies", false)));
|
||||
assert_eq!(settings.profiles[1].account.as_ref().map(|a| (a.handle.as_str(), a.signed_in)), Some(("otheraccount", false)));
|
||||
assert!(!settings.observe("nope", AccountSeen::SignedOut, RULES));
|
||||
}
|
||||
|
||||
|
|
@ -266,7 +266,7 @@ mod tests {
|
|||
bare.avatar = None;
|
||||
settings.observe("default", AccountSeen::SignedIn(bare), RULES);
|
||||
let kept = settings.profiles[0].account.clone().unwrap();
|
||||
assert_eq!((kept.name.as_str(), kept.avatar.is_some()), ("Fishies", true));
|
||||
assert_eq!((kept.name.as_str(), kept.avatar.is_some()), ("Sample", true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -284,12 +284,12 @@ mod tests {
|
|||
#[test]
|
||||
fn a_shell_save_keeps_the_native_accounts() {
|
||||
let mut current = ProfileSettings { profiles: vec![profile("default"), profile("p1")], active: "default".into() };
|
||||
current.observe("p1", AccountSeen::SignedIn(account("playfishies")), RULES);
|
||||
current.observe("p1", AccountSeen::SignedIn(account("otheraccount")), RULES);
|
||||
let mut incoming = ProfileSettings { profiles: vec![profile("default"), profile("p1")], active: "p1".into() };
|
||||
incoming.profiles[0].account = Some(account("forged"));
|
||||
let kept = incoming.keep_accounts_from(¤t);
|
||||
assert_eq!(kept.profiles[0].account, None);
|
||||
assert_eq!(kept.profiles[1].account.as_ref().map(|a| a.handle.as_str()), Some("playfishies"));
|
||||
assert_eq!(kept.profiles[1].account.as_ref().map(|a| a.handle.as_str()), Some("otheraccount"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue