mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 06:25:10 +01:00
removing useless Generic T on selective
, adding tests
This commit is contained in:
parent
cfedb585d3
commit
dad067da44
1 changed files with 22 additions and 2 deletions
|
@ -125,7 +125,7 @@ impl KeyboardMarkup {
|
||||||
/// Sets [`selective`] to `true`.
|
/// Sets [`selective`] to `true`.
|
||||||
///
|
///
|
||||||
/// [`selective`]: KeyboardMarkup::selective
|
/// [`selective`]: KeyboardMarkup::selective
|
||||||
pub fn selective<T>(self) -> Self {
|
pub fn selective(self) -> Self {
|
||||||
Self { selective: true, ..self }
|
Self { selective: true, ..self }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,6 +146,26 @@ mod tests {
|
||||||
"selective": false
|
"selective": false
|
||||||
}
|
}
|
||||||
"#;
|
"#;
|
||||||
serde_json::from_str::<KeyboardMarkup>(data).unwrap();
|
assert!(serde_json::from_str::<KeyboardMarkup>(data).is_ok())
|
||||||
|
}
|
||||||
|
#[test]
|
||||||
|
fn serialize() {
|
||||||
|
let keyboard = vec![
|
||||||
|
vec![
|
||||||
|
KeyboardButton::new("a"),
|
||||||
|
KeyboardButton::new("b"),
|
||||||
|
KeyboardButton::new("c"),
|
||||||
|
KeyboardButton::new("d"),
|
||||||
|
]
|
||||||
|
];
|
||||||
|
let keyboard_markup = KeyboardMarkup::new(keyboard)
|
||||||
|
.persistent()
|
||||||
|
.resize_keyboard()
|
||||||
|
.selective()
|
||||||
|
.one_time_keyboard();
|
||||||
|
let expected = r#"{"keyboard":[[{"text":"a"},{"text":"b"},{"text":"c"},{"text":"d"}]],"is_persistent":true,"resize_keyboard":true,"one_time_keyboard":true,"selective":true}"#;
|
||||||
|
|
||||||
|
assert!(serde_json::ser::to_string(&keyboard_markup).is_ok_and(|s|s.eq(expected)));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue