Skip to content

Commit

Permalink
Allow import of layout_test into 3rd party crates (#3463)
Browse files Browse the repository at this point in the history
* Expose layout tests

Currently I can't import tests because `cfg(test)` isn't sent to sub-dependencies.   This allows you to set a `yew/test` and import into your own tests.

* Update Cargo.toml

* Update lib.rs

* Update lib.rs

* Update lib.rs

* AnyScope::test needs feature = test cfg + fmt

---------

Co-authored-by: Elina <[email protected]>
  • Loading branch information
rollo-b2c2 and ranile authored Oct 14, 2024
1 parent a80542f commit 4025fa7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/yew/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ ssr = ["dep:html-escape", "dep:base64ct", "dep:bincode"]
csr = []
hydration = ["csr", "dep:bincode"]
default = []
test = []

[package.metadata.docs.rs]
all-features = true
Expand Down
2 changes: 1 addition & 1 deletion packages/yew/src/html/component/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ mod feat_csr {
use crate::scheduler;

impl AnyScope {
#[cfg(test)]
#[cfg(any(test, feature = "test"))]
pub(crate) fn test() -> Self {
Self {
type_id: TypeId::of::<()>(),
Expand Down
3 changes: 1 addition & 2 deletions packages/yew/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,7 @@ mod app_handle;
#[cfg(feature = "csr")]
mod renderer;

#[cfg(feature = "csr")]
#[cfg(test)]
#[cfg(all(feature = "csr", any(test, feature = "test")))]
#[allow(missing_docs)]
pub mod tests;

Expand Down

0 comments on commit 4025fa7

Please sign in to comment.