Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry committed Nov 22, 2020
1 parent 62e8e9c commit 5415fe1
Show file tree
Hide file tree
Showing 41 changed files with 162 additions and 224 deletions.
2 changes: 1 addition & 1 deletion docs/concepts/components/properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fn create_default_link_color() -> LinkColor {
LinkColor::Blue
}

#[derive(Properties, Clone, PartialEq)]
#[derive(Properties, PartialEq)]
pub struct LinkProps {
/// The link must have a target.
href: String,
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/function-components/attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ html! { <ChatContainer /> }
<!--DOCUSAURUS_CODE_TABS-->
<!--With props-->
```rust
#[derive(Properties, Clone, PartialEq)]
#[derive(Properties, PartialEq)]
pub struct RenderedAtProps {
pub time: String,
}
Expand Down
4 changes: 2 additions & 2 deletions docs/concepts/html/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ html! {
Here's the implementation of `Container`:

```rust
#[derive(Properties, Clone)]
#[derive(Properties, PartialEq)]
pub struct Props {
pub id: String,
pub children: Children,
Expand Down Expand Up @@ -90,7 +90,7 @@ html! {
```

```rust
#[derive(Properties, Clone)]
#[derive(Properties, PartialEq)]
pub struct Props {
pub children: ChildrenWithProps<ListItem>,
}
Expand Down
2 changes: 1 addition & 1 deletion examples/boids/src/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub enum Msg {
Tick,
}

#[derive(Clone, Debug, PartialEq, Properties)]
#[derive(Debug, PartialEq, Properties)]
pub struct Props {
pub settings: Settings,
#[prop_or_default]
Expand Down
2 changes: 1 addition & 1 deletion examples/crm/src/add_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub enum Msg {
Abort,
}

#[derive(Clone, Debug, PartialEq, Properties)]
#[derive(Debug, PartialEq, Properties)]
pub struct Props {
pub on_add: Callback<Client>,
pub on_abort: Callback<()>,
Expand Down
2 changes: 1 addition & 1 deletion examples/router/src/components/author_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
};
use yew::prelude::*;

#[derive(Clone, Debug, PartialEq, Properties)]
#[derive(Debug, PartialEq, Properties)]
pub struct Props {
pub seed: u64,
}
Expand Down
2 changes: 1 addition & 1 deletion examples/router/src/components/pagination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use yew::prelude::*;

const ELLIPSIS: &str = "\u{02026}";

#[derive(Clone, Debug, PartialEq, Properties)]
#[derive(Debug, PartialEq, Properties)]
pub struct Props {
pub page: u64,
pub total_pages: u64,
Expand Down
2 changes: 1 addition & 1 deletion examples/router/src/components/post_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
};
use yew::prelude::*;

#[derive(Clone, Debug, PartialEq, Properties)]
#[derive(Debug, PartialEq, Properties)]
pub struct Props {
pub seed: u64,
}
Expand Down
2 changes: 1 addition & 1 deletion examples/router/src/components/progress_delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub enum Msg {
Tick,
}

#[derive(Clone, Debug, PartialEq, Properties)]
#[derive(Debug, PartialEq, Properties)]
pub struct Props {
pub duration_ms: u64,
pub on_complete: Callback<()>,
Expand Down
2 changes: 1 addition & 1 deletion examples/router/src/pages/author.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{content, generator::Generated};
use yew::prelude::*;

#[derive(Clone, Debug, Eq, PartialEq, Properties)]
#[derive(Debug, Eq, PartialEq, Properties)]
pub struct Props {
pub seed: u64,
}
Expand Down
2 changes: 1 addition & 1 deletion examples/router/src/pages/page_not_found.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use yew::prelude::*;

#[derive(Clone, Debug, Eq, PartialEq, Properties)]
#[derive(Debug, Eq, PartialEq, Properties)]
pub struct Props {
pub route: Option<String>,
}
Expand Down
2 changes: 1 addition & 1 deletion examples/router/src/pages/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
use content::PostPart;
use yew::prelude::*;

#[derive(Clone, Debug, Eq, PartialEq, Properties)]
#[derive(Debug, Eq, PartialEq, Properties)]
pub struct Props {
pub seed: u64,
}
Expand Down
2 changes: 1 addition & 1 deletion examples/router/src/pages/post_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub enum Msg {
ShowPage(u64),
}

#[derive(Clone, Debug, Eq, PartialEq, Properties)]
#[derive(Debug, Eq, PartialEq, Properties)]
pub struct Props {
pub page: u64,
}
Expand Down
2 changes: 1 addition & 1 deletion examples/store/src/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub enum Msg {
PostStoreMsg(ReadOnly<PostStore>),
}

#[derive(Properties, Clone, PartialEq)]
#[derive(Properties, PartialEq)]
pub struct Props {
pub id: PostId,
}
Expand Down
2 changes: 1 addition & 1 deletion examples/store/src/text_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub enum Msg {
Submit,
}

#[derive(Properties, Clone, PartialEq)]
#[derive(Properties, PartialEq)]
pub struct Props {
pub value: String,
pub onsubmit: Callback<String>,
Expand Down
12 changes: 6 additions & 6 deletions yew-components/src/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ use yew::{html, Component, Context, Properties};
///# use std::fmt;
///# use yew::{Html, Component, Context, html};
///# use yew_components::Select;
/// #[derive(PartialEq)]
/// #[derive(Clone, PartialEq)]
/// enum Scene {
/// First,
/// Second,
/// }
///# struct Model { link: ComponentLink<Self> };
///# struct Model;
///# impl Component for Model {
///# type Message = ();type Properties = ();
///# fn create(ctx: &Context<Self>) -> Self {unimplemented!()}
///# fn view(&self) -> Html {unimplemented!()}}
///# fn view(&self, ctx: &Context<Self>) -> Html {unimplemented!()}}
/// impl fmt::Display for Scene {
/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
/// match self {
Expand All @@ -49,7 +49,7 @@ use yew::{html, Component, Context, Properties};
/// Only the `on_change` property is mandatory. Other (optional) properties
/// are `selected`, `disabled`, `options`, `class`, `id`, and `placeholder`.
#[derive(Debug)]
pub struct Select<T: ToString + PartialEq + Clone + 'static> {
pub struct Select<T: ToString + PartialEq + 'static> {
_marker: PhantomData<T>,
select_ref: NodeRef,
}
Expand All @@ -62,8 +62,8 @@ pub enum Msg {
}

/// Properties of the `Select` component.
#[derive(PartialEq, Clone, Properties, Debug)]
pub struct Props<T: PartialEq> {
#[derive(PartialEq, Properties, Debug)]
pub struct Props<T: PartialEq + Clone> {
/// Initially selected value.
#[prop_or_default]
pub selected: Option<T>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use yew::prelude::*;
use yew_functional::function_component;

#[derive(Clone, Properties, PartialEq)]
#[derive(Properties, PartialEq)]
struct Props {
a: usize,
}
Expand Down
2 changes: 1 addition & 1 deletion yew-functional-macro/tests/function_attr/bad-name-fail.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use yew::prelude::*;
use yew_functional::function_component;

#[derive(Clone, Properties, PartialEq)]
#[derive(Properties, PartialEq)]
struct Props {
a: usize,
}
Expand Down
2 changes: 1 addition & 1 deletion yew-functional/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub use use_context_hook::*;
/// # use yew_functional::function_component;
/// # use yew::prelude::*;
/// #
/// # #[derive(Properties, Clone, PartialEq)]
/// # #[derive(Properties, PartialEq)]
/// # pub struct Props {
/// # text: String
/// # }
Expand Down
6 changes: 3 additions & 3 deletions yew-functional/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fn multiple_use_state_setters() {
#[wasm_bindgen_test]
fn props_are_passed() {
struct PropsPassedFunction {}
#[derive(Properties, Clone, PartialEq)]
#[derive(Properties, PartialEq)]
struct PropsPassedFunctionProps {
value: String,
}
Expand Down Expand Up @@ -192,7 +192,7 @@ fn use_reducer_works() {
fn use_effect_destroys_on_component_drop() {
struct UseEffectFunction {}
struct UseEffectWrapper {}
#[derive(Properties, Clone)]
#[derive(Properties)]
struct WrapperProps {
destroy_called: Rc<dyn Fn()>,
}
Expand All @@ -201,7 +201,7 @@ fn use_effect_destroys_on_component_drop() {
false
}
}
#[derive(Properties, Clone)]
#[derive(Properties)]
struct FunctionProps {
effect_called: Rc<dyn Fn()>,
destroy_called: Rc<dyn Fn()>,
Expand Down
20 changes: 5 additions & 15 deletions yew-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
//! ```
//! use yew::prelude::*;
//!
//! struct Component {
//! link: ComponentLink<Self>,
//! }
//! struct Component;
//!
//! #[derive(Clone, Properties)]
//! #[derive(PartialEq, Properties)]
//! struct Props {
//! prop: String,
//! };
Expand All @@ -19,25 +17,17 @@
//! # impl yew::Component for Component {
//! # type Message = Msg;
//! # type Properties = Props;
//! # fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
//! # unimplemented!()
//! # }
//! #
//! # fn update(&mut self, msg: Self::Message) -> ShouldRender {
//! # unimplemented!()
//! # }
//! #
//! # fn change(&mut self, props: Self::Properties) -> ShouldRender {
//! # fn create(_: &Context<Self>) -> Self {
//! # unimplemented!()
//! # }
//! #
//! # fn view(&self) -> Html {
//! # fn view(&self, ctx: &Context<Self>) -> Html {
//! #
//! // ...
//!
//! html! {
//! <div>
//! <button onclick=self.link.callback(|_| Msg::Submit)>
//! <button onclick=ctx.callback(|_| Msg::Submit)>
//! { "Submit" }
//! </button>
//! <>
Expand Down
20 changes: 10 additions & 10 deletions yew-macro/tests/derive_props/fail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod t1 {
use super::*;
#[derive(Clone)]
struct Value;
#[derive(Clone, Properties)]
#[derive(PartialEq, Properties)]
pub struct Props {
// ERROR: optional params must implement default
#[prop_or_default]
Expand All @@ -16,7 +16,7 @@ mod t1 {

mod t2 {
use super::*;
#[derive(Clone, Properties)]
#[derive(PartialEq, Properties)]
pub struct Props {
// ERROR: old syntax no longer supported
#[props(default)]
Expand All @@ -26,7 +26,7 @@ mod t2 {

mod t3 {
use super::*;
#[derive(Clone, Properties)]
#[derive(PartialEq, Properties)]
pub struct Props {
value: String,
}
Expand All @@ -38,7 +38,7 @@ mod t3 {

mod t4 {
use super::*;
#[derive(Clone, Properties)]
#[derive(PartialEq, Properties)]
pub struct Props {
b: i32,
a: i32,
Expand All @@ -51,7 +51,7 @@ mod t4 {

mod t5 {
use super::*;
#[derive(Clone, Properties)]
#[derive(PartialEq, Properties)]
pub struct Props {
// ERROR: prop_or must be given a value
#[prop_or()]
Expand All @@ -61,7 +61,7 @@ mod t5 {

mod t6 {
use super::*;
#[derive(Clone, Properties)]
#[derive(PartialEq, Properties)]
pub struct Props {
// ERROR: 123 is not a String
#[prop_or(123)]
Expand All @@ -71,7 +71,7 @@ mod t6 {

mod t7 {
use super::*;
#[derive(Clone, Properties)]
#[derive(PartialEq, Properties)]
pub struct Props {
// ERROR: 123 is not a function
#[prop_or_else(123)]
Expand All @@ -81,7 +81,7 @@ mod t7 {

mod t8 {
use super::*;
#[derive(Clone, Properties)]
#[derive(PartialEq, Properties)]
pub struct Props {
// ERROR: cannot find function foo in this scope
#[prop_or_else(foo)]
Expand All @@ -91,7 +91,7 @@ mod t8 {

mod t9 {
use super::*;
#[derive(Clone, Properties)]
#[derive(PartialEq, Properties)]
pub struct Props {
// ERROR: the function must take no arguments
#[prop_or_else(foo)]
Expand All @@ -105,7 +105,7 @@ mod t9 {

mod t10 {
use super::*;
#[derive(Clone, Properties)]
#[derive(PartialEq, Properties)]
pub struct Props {
// ERROR: the function returns incompatible types
#[prop_or_else(foo)]
Expand Down
6 changes: 3 additions & 3 deletions yew-macro/tests/derive_props/fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ help: consider importing one of these items
error[E0277]: the trait bound `t1::Value: std::default::Default` is not satisfied
--> $DIR/fail.rs:9:21
|
9 | #[derive(Clone, Properties)]
9 | #[derive(PartialEq, Properties)]
| ^^^^^^^^^^ the trait `std::default::Default` is not implemented for `t1::Value`
|
= note: required by `std::default::Default::default`
Expand All @@ -35,7 +35,7 @@ error[E0277]: the trait bound `t1::Value: std::default::Default` is not satisfie
error[E0599]: no method named `build` found for struct `t3::PropsBuilder<t3::PropsBuilderStep_missing_required_prop_value>` in the current scope
--> $DIR/fail.rs:35:26
|
29 | #[derive(Clone, Properties)]
29 | #[derive(PartialEq, Properties)]
| ---------- method `build` not found for this
...
35 | Props::builder().build();
Expand All @@ -48,7 +48,7 @@ error[E0599]: no method named `build` found for struct `t3::PropsBuilder<t3::Pro
error[E0599]: no method named `b` found for struct `t4::PropsBuilder<t4::PropsBuilderStep_missing_required_prop_a>` in the current scope
--> $DIR/fail.rs:48:26
|
41 | #[derive(Clone, Properties)]
41 | #[derive(PartialEq, Properties)]
| ---------- method `b` not found for this
...
48 | Props::builder().b(1).a(2).build();
Expand Down

0 comments on commit 5415fe1

Please sign in to comment.