Work on tests

This commit is contained in:
Conrad Irwin 2024-01-21 21:59:41 -07:00
parent 9d261cf859
commit 4143d3a36e
10 changed files with 181 additions and 35 deletions

View file

@ -42,6 +42,7 @@ pub enum NeovimData {
Key(String),
Get { state: String, mode: Option<Mode> },
ReadRegister { name: char, value: String },
Exec { command: String },
SetOption { value: String },
}
@ -269,6 +270,32 @@ impl NeovimConnection {
);
}
#[cfg(feature = "neovim")]
pub async fn exec(&mut self, value: &str) {
self.nvim
.command_output(format!("{}", value).as_str())
.await
.unwrap();
self.data.push_back(NeovimData::Exec {
command: value.to_string(),
})
}
#[cfg(not(feature = "neovim"))]
pub async fn exec(&mut self, value: &str) {
if let Some(NeovimData::Get { .. }) = self.data.front() {
self.data.pop_front();
};
assert_eq!(
self.data.pop_front(),
Some(NeovimData::Exec {
command: value.to_string(),
}),
"operation does not match recorded script. re-record with --features=neovim"
);
}
#[cfg(not(feature = "neovim"))]
pub async fn read_register(&mut self, register: char) -> String {
if let Some(NeovimData::Get { .. }) = self.data.front() {