mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-30 06:05:19 +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 {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{actions, elements::*, impl_actions, MouseButton, MouseButtonEvent};
|
use crate::{actions, elements::*, impl_actions, MouseButton, MouseButtonEvent};
|
||||||
|
use postage::{sink::Sink, stream::Stream};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use smol::future::poll_once;
|
use smol::future::poll_once;
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -6894,6 +6895,23 @@ mod tests {
|
||||||
assert_eq!(presenter.borrow().rendered_views.len(), 1);
|
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)]
|
#[crate::test(self)]
|
||||||
async fn test_window_activation(cx: &mut TestAppContext) {
|
async fn test_window_activation(cx: &mut TestAppContext) {
|
||||||
struct View(&'static str);
|
struct View(&'static str);
|
||||||
|
|
Loading…
Reference in a new issue