Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
photovoltex committed Mar 20, 2024
1 parent 4e6729c commit af5f785
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ jobs:
cd tauri-interop-macro
cargo test --features event,leptos,initial_value
- name: Run tests for crate
- name: Run tests for crate (no features)
run: cargo test --features=event

- name: Run tests for crate (all-features)
run: cargo test --all-features

- name: Build test-project (wasm)
Expand Down
19 changes: 11 additions & 8 deletions src/event.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde::{de::DeserializeOwned, Serialize};
#[cfg(any(feature = "initial_value", doc))]
use serde::Deserialize;
#[cfg(not(target_family = "wasm"))]
use tauri::{AppHandle, Error, Wry};

Expand All @@ -24,15 +26,15 @@ mod listen;
#[allow(clippy::needless_doctest_main)]
/// Trait defining a [Field] to a related struct implementing [Parent] with the related [Field::Type]
///
/// When using [Event], [Emit] or [Listen], for each field of the struct, a struct named after the
/// When using [Event], [Emit] or [Listen], for each field of the struct, a struct named after the
/// field is generated. The field naming is snake_case to PascalCase, but because of the possibility
/// that the type and the field name are the same, the generated field has a "F" appended at the
/// that the type and the field name are the same, the generated field has a "F" appended at the
/// beginning to separate each other and avoid type collision.
///
///
/// ```
/// use serde::{Deserialize, Serialize};
/// use tauri_interop::{Event, event::ManagedEmit};
///
/// use tauri_interop::Event;
///
/// #[derive(Default, Clone, Serialize, Deserialize)]
/// struct Bar {
/// foo: u16
Expand All @@ -42,8 +44,9 @@ mod listen;
/// struct Test {
/// bar: Bar
/// }
///
/// impl ManagedEmit for Test {}
///
/// #[cfg(feature = "initial_value")]
/// impl tauri_interop::event::ManagedEmit for Test {}
///
/// fn main() {
/// let _ = test::FBar;
Expand Down
7 changes: 5 additions & 2 deletions src/event/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub trait Emit: Sized {
/// pub bar: bool,
/// }
///
/// #[cfg(feature = "initial_value")]
/// impl tauri_interop::event::ManagedEmit for Test {}
///
/// #[tauri_interop::command]
Expand All @@ -85,6 +86,7 @@ pub trait Emit: Sized {
/// pub bar: bool,
/// }
///
/// #[cfg(feature = "initial_value")]
/// impl tauri_interop::event::ManagedEmit for Test {}
///
/// #[tauri_interop::command]
Expand All @@ -103,15 +105,16 @@ pub trait Emit: Sized {
/// ### Example
///
/// ```
/// use tauri_interop::{command::TauriAppHandle, event::Emit, Event};
/// use tauri_interop::{command::TauriAppHandle, Event, event::Emit};
///
///
/// #[derive(Default, Event)]
/// pub struct Test {
/// foo: String,
/// pub bar: bool,
/// }
///
/// // require because we compile
/// #[cfg(feature = "initial_value")]
/// impl tauri_interop::event::ManagedEmit for Test {}
///
/// #[tauri_interop::command]
Expand Down

0 comments on commit af5f785

Please sign in to comment.