Skip to content

Commit 8f5911b

Browse files
committed
Fix wp_contextual tests by adding SparseField trait for tests
1 parent 8eadb82 commit 8f5911b

7 files changed

+34
-0
lines changed

wp_contextual/src/lib.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787
//! pub rendered: Option<String>,
8888
//! }
8989
//!
90+
//! # // We need this line because `WpContextual` implements `crate::SparseField`
91+
//! # trait SparseField { fn as_mapped_field_name(&self) -> &str; }
9092
//! # // We need these 2 lines for UniFFI
9193
//! # uniffi::setup_scaffolding!();
9294
//! # fn main() {}
@@ -123,6 +125,8 @@
123125
//! #[WpContext(edit, view)]
124126
//! pub rendered: Option<String>,
125127
//! }
128+
//! # // We need this line because `WpContextual` implements `crate::SparseField`
129+
//! # trait SparseField { fn as_mapped_field_name(&self) -> &str; }
126130
//! # // We need these 2 lines for UniFFI
127131
//! # uniffi::setup_scaffolding!();
128132
//! # fn main() {}
@@ -168,6 +172,8 @@
168172
//! # #[WpContext(edit, view)]
169173
//! # pub rendered: Option<String>,
170174
//! # }
175+
//! # // We need this line because `WpContextual` implements `crate::SparseField`
176+
//! # trait SparseField { fn as_mapped_field_name(&self) -> &str; }
171177
//! # // We need these 2 lines for UniFFI
172178
//! # uniffi::setup_scaffolding!();
173179
//! # fn main() {}
@@ -212,6 +218,8 @@
212218
//! # #[WpContext(edit, view)]
213219
//! # pub rendered: Option<String>,
214220
//! # }
221+
//! # // We need this line because `WpContextual` implements `crate::SparseField`
222+
//! # trait SparseField { fn as_mapped_field_name(&self) -> &str; }
215223
//! # // We need these 2 lines for UniFFI
216224
//! # uniffi::setup_scaffolding!();
217225
//! # fn main() {}
@@ -253,6 +261,8 @@
253261
//! #[WpContextualOption]
254262
//! pub avatar_urls: Option<HashMap<String, String>>,
255263
//! }
264+
//! # // We need this line because `WpContextual` implements `crate::SparseField`
265+
//! # trait SparseField { fn as_mapped_field_name(&self) -> &str; }
256266
//! # // We need these 2 lines for UniFFI
257267
//! # uniffi::setup_scaffolding!();
258268
//! # fn main() {}
@@ -283,6 +293,8 @@
283293
//! #[WpContextualExcludeFromFields]
284294
//! pub additional_fields: Option<String>,
285295
//! }
296+
//! # // We need this line because `WpContextual` implements `crate::SparseField`
297+
//! # trait SparseField { fn as_mapped_field_name(&self) -> &str; }
286298
//! # // We need these 2 lines for UniFFI
287299
//! # uniffi::setup_scaffolding!();
288300
//! # fn main() {}
@@ -324,6 +336,8 @@
324336
//! #[WpContext(edit, view)]
325337
//! pub baz: Option<u32>,
326338
//! }
339+
//! # // We need this line because `WpContextual` implements `crate::SparseField`
340+
//! # trait SparseField { fn as_mapped_field_name(&self) -> &str; }
327341
//! # // We need these 2 lines for UniFFI
328342
//! # uniffi::setup_scaffolding!();
329343
//! # fn main() {}
@@ -415,6 +429,8 @@ mod wp_contextual;
415429
/// #[WpContext(edit)]
416430
/// pub qux: Option<Vec<u32>>,
417431
/// }
432+
/// # // We need this line because `WpContextual` implements `crate::SparseField`
433+
/// # trait SparseField { fn as_mapped_field_name(&self) -> &str; }
418434
/// # // We need these 2 lines for UniFFI
419435
/// # uniffi::setup_scaffolding!();
420436
/// # fn main() {}

wp_contextual/tests/basic_wp_contextual.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use wp_contextual::WpContextual;
22

3+
mod sparse_field_trait;
4+
pub use sparse_field_trait::SparseField;
5+
36
#[derive(WpContextual)]
47
pub struct SparseFoo {
58
#[WpContext(edit, embed, view)]

wp_contextual/tests/basic_wp_contextual_field.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use std::collections::HashMap;
22
use wp_contextual::WpContextual;
33

4+
mod sparse_field_trait;
5+
pub use sparse_field_trait::SparseField;
6+
47
#[derive(WpContextual)]
58
pub struct SparseFoo {
69
#[WpContext(edit)]

wp_contextual/tests/basic_wp_contextual_option.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use wp_contextual::WpContextual;
22

3+
mod sparse_field_trait;
4+
pub use sparse_field_trait::SparseField;
5+
36
#[derive(WpContextual)]
47
pub struct SparseFoo {
58
#[WpContext(edit)]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub trait SparseField {
2+
fn as_mapped_field_name(&self) -> &str;
3+
}

wp_contextual/tests/wp_contextual_field_with_inner_type.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use wp_contextual::WpContextual;
22

3+
mod sparse_field_trait;
4+
pub use sparse_field_trait::SparseField;
5+
36
#[derive(WpContextual)]
47
pub struct SparseFoo {
58
#[WpContext(edit)]

wp_contextual/tests/wp_contextual_field_with_multiple_segments.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use wp_contextual::WpContextual;
22

3+
mod sparse_field_trait;
4+
pub use sparse_field_trait::SparseField;
5+
36
// This test is validating that we are able to handle `#[WpContextualField]`s if its type
47
// has multiple path segments. That's why we use a helper mod and use fully qualified paths
58
// rather than the importing the mod.

0 commit comments

Comments
 (0)