Skip to content

Commit

Permalink
Fix tests for virtual component
Browse files Browse the repository at this point in the history
  • Loading branch information
therustmonk committed Jun 8, 2018
1 parent edcc898 commit 41a22eb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
24 changes: 11 additions & 13 deletions tests/vcomp_test.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#[macro_use]
extern crate yew;

use yew::html::{Component, Env, Html, Renderable, ShouldRender};
use yew::prelude::*;
use yew::virtual_dom::VNode;

type Ctx = ();

struct Comp;

#[derive(PartialEq, Clone)]
Expand All @@ -23,40 +21,40 @@ impl Default for Props {
}
}

impl Component<Ctx> for Comp {
impl Component for Comp {
type Message = ();
type Properties = Props;

fn create(_: Self::Properties, _: &mut Env<Ctx, Self>) -> Self {
fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
Comp
}

fn update(&mut self, _: Self::Message, _: &mut Env<Ctx, Self>) -> ShouldRender {
fn update(&mut self, _: Self::Message) -> ShouldRender {
unimplemented!();
}
}

impl Renderable<Ctx, Comp> for Comp {
fn view(&self) -> Html<Ctx, Self> {
impl Renderable<Comp> for Comp {
fn view(&self) -> Html<Self> {
unimplemented!();
}
}

#[test]
fn set_properties_to_component() {
let _: VNode<Ctx, Comp> = html! {
let _: VNode<Comp> = html! {
<Comp: />
};

let _: VNode<Ctx, Comp> = html! {
let _: VNode<Comp> = html! {
<Comp: field_1=1, />
};

let _: VNode<Ctx, Comp> = html! {
let _: VNode<Comp> = html! {
<Comp: field_2=2, />
};

let _: VNode<Ctx, Comp> = html! {
let _: VNode<Comp> = html! {
<Comp: field_1=1, field_2=2, />
};

Expand All @@ -65,7 +63,7 @@ fn set_properties_to_component() {
field_2: 1,
};

let _: VNode<Ctx, Comp> = html! {
let _: VNode<Comp> = html! {
<Comp: with props, field_2=2, />
};
}
2 changes: 1 addition & 1 deletion tests/vlist_test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[macro_use]
extern crate yew;

use yew::html::{Component, ComponentLink, Html, Renderable, ShouldRender};
use yew::prelude::*;
use yew::virtual_dom::VNode;

struct Comp;
Expand Down
2 changes: 1 addition & 1 deletion tests/vtag_test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[macro_use]
extern crate yew;

use yew::html::{Component, ComponentLink, Html, Renderable, ShouldRender};
use yew::prelude::*;
use yew::virtual_dom::VNode;

struct Comp;
Expand Down

0 comments on commit 41a22eb

Please sign in to comment.