Run until parked now that the command palette spawns to dispatch action

This commit is contained in:
Antonio Scandurra 2023-05-01 16:58:07 +02:00
parent 6c931ab9da
commit e3b2407ebf

View File

@ -268,9 +268,11 @@ impl std::fmt::Debug for Command {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::sync::Arc;
use super::*; use super::*;
use editor::Editor; use editor::Editor;
use gpui::TestAppContext; use gpui::{executor::Deterministic, TestAppContext};
use project::Project; use project::Project;
use workspace::{AppState, Workspace}; use workspace::{AppState, Workspace};
@ -291,7 +293,8 @@ mod tests {
} }
#[gpui::test] #[gpui::test]
async fn test_command_palette(cx: &mut TestAppContext) { async fn test_command_palette(deterministic: Arc<Deterministic>, cx: &mut TestAppContext) {
deterministic.forbid_parking();
let app_state = cx.update(AppState::test); let app_state = cx.update(AppState::test);
cx.update(|cx| { cx.update(|cx| {
@ -333,7 +336,7 @@ mod tests {
assert_eq!(palette.delegate().matches[0].string, "editor: backspace"); assert_eq!(palette.delegate().matches[0].string, "editor: backspace");
palette.confirm(&Default::default(), cx); palette.confirm(&Default::default(), cx);
}); });
deterministic.run_until_parked();
editor.read_with(cx, |editor, cx| { editor.read_with(cx, |editor, cx| {
assert_eq!(editor.text(cx), "ab"); assert_eq!(editor.text(cx), "ab");
}); });