Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Rust testing framework #187

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"dev": "dotenv -e ../../.env -- tauri dev",
"localdev": "dotenv -e ../../.env -- vinxi dev --port 3001",
"build": "vinxi build",
"tauri": "tauri"
"tauri": "tauri",
"test:desktop": "cargo test --manifest-path src-tauri/Cargo.toml"
},
"dependencies": {
"@cap/database": "workspace:*",
Expand Down
49 changes: 49 additions & 0 deletions apps/desktop/src-tauri/tests/desktop_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#[cfg(test)]
mod tests {
use super::*;
use tauri::AppHandle;
use std::path::PathBuf;

#[tokio::test]
async fn test_start_recording() {
let app = AppHandle::default();
let state = MutableState::default();
let result = start_recording(app, state).await;
assert!(result.is_ok());
}

#[tokio::test]
async fn test_stop_recording() {
let app = AppHandle::default();
let state = MutableState::default();
let result = stop_recording(app, state).await;
assert!(result.is_ok());
}

#[tokio::test]
async fn test_copy_file_to_path() {
let app = AppHandle::default();
let src = "test_src.txt".to_string();
let dst = "test_dst.txt".to_string();
let result = copy_file_to_path(app, src, dst).await;
assert!(result.is_ok());
}

#[tokio::test]
async fn test_copy_screenshot_to_clipboard() {
let app = AppHandle::default();
let path = PathBuf::from("test_screenshot.png");
let result = copy_screenshot_to_clipboard(app, path).await;
assert!(result.is_ok());
}

#[tokio::test]
async fn test_export_video() {
let app = AppHandle::default();
let video_id = "test_video_id".to_string();
let project = ProjectConfiguration::default();
let progress = tauri::ipc::Channel::new(|_| Ok(()));
let result = export_video(app, video_id, project, progress, true).await;
assert!(result.is_ok());
}
}