mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-27 12:54:42 +00:00
Add basic test for labeled tasks
This commit is contained in:
parent
3564e95f27
commit
6b6e4e3bfe
1 changed files with 18 additions and 0 deletions
|
@ -5279,6 +5279,7 @@ impl Subscription {
|
|||
mod tests {
|
||||
use super::*;
|
||||
use crate::{actions, elements::*, impl_actions, MouseButton, MouseButtonEvent};
|
||||
use postage::{sink::Sink, stream::Stream};
|
||||
use serde::Deserialize;
|
||||
use smol::future::poll_once;
|
||||
use std::{
|
||||
|
@ -6894,6 +6895,23 @@ mod tests {
|
|||
assert_eq!(presenter.borrow().rendered_views.len(), 1);
|
||||
}
|
||||
|
||||
#[crate::test(self)]
|
||||
async fn test_labeled_tasks(cx: &mut TestAppContext) {
|
||||
assert_eq!(None, cx.update(|cx| cx.active_labeled_tasks().next()));
|
||||
let (mut sender, mut reciever) = postage::oneshot::channel::<()>();
|
||||
let task = cx
|
||||
.update(|cx| cx.spawn_labeled("Test Label", |_| async move { reciever.recv().await }));
|
||||
|
||||
assert_eq!(
|
||||
Some("Test Label"),
|
||||
cx.update(|cx| cx.active_labeled_tasks().next())
|
||||
);
|
||||
sender.send(()).await;
|
||||
task.await;
|
||||
|
||||
assert_eq!(None, cx.update(|cx| cx.active_labeled_tasks().next()));
|
||||
}
|
||||
|
||||
#[crate::test(self)]
|
||||
async fn test_window_activation(cx: &mut TestAppContext) {
|
||||
struct View(&'static str);
|
||||
|
|
Loading…
Reference in a new issue