AppFlowy/frontend/rust-lib/flowy-test/src/editor.rs
2021-12-10 11:21:45 +08:00

23 lines
654 B
Rust

use crate::{helper::ViewTest, FlowySDKTest};
use flowy_document::services::doc::edit::ClientDocEditor;
use flowy_document_infra::entities::doc::DocIdentifier;
use std::sync::Arc;
pub struct EditorTest {
pub sdk: FlowySDKTest,
}
impl EditorTest {
pub async fn new() -> Self {
let sdk = FlowySDKTest::setup();
let _ = sdk.init_user().await;
Self { sdk }
}
pub async fn create_doc(&self) -> Arc<ClientDocEditor> {
let test = ViewTest::new(&self.sdk).await;
let doc_identifier: DocIdentifier = test.view.id.clone().into();
self.sdk.flowy_document.open(doc_identifier).await.unwrap()
}
}