Hoisted assert clipboard into TestAppContext

This commit is contained in:
Mikayla Maki 2022-07-07 13:29:58 -07:00
parent 9209c0dfeb
commit 2a6e23ff28
4 changed files with 9 additions and 17 deletions

View file

@ -8232,7 +8232,7 @@ mod tests {
fox ju|mps over
the lazy dog"});
cx.update_editor(|e, cx| e.copy(&Copy, cx));
cx.assert_clipboard_content(Some("fox jumps over\n"));
cx.cx.assert_clipboard_content(Some("fox jumps over\n"));
// Paste with three selections, noticing how the copied full-line selection is inserted
// before the empty selections but replaces the selection that is non-empty.

View file

@ -404,14 +404,6 @@ impl<'a> EditorTestContext<'a> {
editor_text_with_selections
}
pub fn assert_clipboard_content(&mut self, expected_content: Option<&str>) {
self.cx.update(|cx| {
let actual_content = cx.read_from_clipboard().map(|item| item.text().to_owned());
let expected_content = expected_content.map(|content| content.to_owned());
assert_eq!(actual_content, expected_content);
})
}
}
impl<'a> Deref for EditorTestContext<'a> {

View file

@ -627,6 +627,14 @@ impl TestAppContext {
}
})
}
pub fn assert_clipboard_content(&mut self, expected_content: Option<&str>) {
self.update(|cx| {
let actual_content = cx.read_from_clipboard().map(|item| item.text().to_owned());
let expected_content = expected_content.map(|content| content.to_owned());
assert_eq!(actual_content, expected_content);
})
}
}
impl AsyncAppContext {

View file

@ -147,14 +147,6 @@ impl<'a> VimTestContext<'a> {
let mode = self.mode();
VimBindingTestContext::new(keystrokes, mode, mode, self)
}
pub fn assert_clipboard_content(&mut self, expected_content: Option<&str>) {
self.cx.update(|cx| {
let actual_content = cx.read_from_clipboard().map(|item| item.text().to_owned());
let expected_content = expected_content.map(|content| content.to_owned());
assert_eq!(actual_content, expected_content);
})
}
}
impl<'a> Deref for VimTestContext<'a> {