Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry committed May 4, 2020
1 parent 6e01b54 commit 7586302
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
6 changes: 3 additions & 3 deletions yew/src/html/scope.rs
Expand Up @@ -30,9 +30,9 @@ pub(crate) enum ComponentUpdate<COMP: Component> {
/// Untyped scope used for accessing parent scope
#[derive(Debug, Clone)]
pub struct AnyScope {
type_id: TypeId,
parent: Option<Rc<AnyScope>>,
state: Rc<dyn Any>,
pub(crate) type_id: TypeId,
pub(crate) parent: Option<Rc<AnyScope>>,
pub(crate) state: Rc<dyn Any>,
}

impl<COMP: Component> From<Scope<COMP>> for AnyScope {
Expand Down
21 changes: 15 additions & 6 deletions yew/src/virtual_dom/vtag.rs
Expand Up @@ -507,6 +507,7 @@ where
mod tests {
use super::*;
use crate::{html, Component, ComponentLink, Html, ShouldRender};
use std::any::TypeId;
#[cfg(feature = "std_web")]
use stdweb::web::{document, IElement};
#[cfg(feature = "wasm_test")]
Expand All @@ -515,6 +516,14 @@ mod tests {
#[cfg(feature = "wasm_test")]
wasm_bindgen_test_configure!(run_in_browser);

fn test_scope() -> AnyScope {
AnyScope {
type_id: TypeId::of::<()>(),
parent: None,
state: Rc::new(()),
}
}

struct Comp;

impl Component for Comp {
Expand Down Expand Up @@ -839,7 +848,7 @@ mod tests {
#[cfg(feature = "web_sys")]
let document = web_sys::window().unwrap().document().unwrap();

let scope = AnyScope::default();
let scope = test_scope();
let div_el = document.create_element("div").unwrap();
let namespace = SVG_NAMESPACE;
#[cfg(feature = "web_sys")]
Expand Down Expand Up @@ -982,7 +991,7 @@ mod tests {

#[test]
fn it_does_not_set_empty_class_name() {
let scope = AnyScope::default();
let scope = test_scope();
let parent = document().create_element("div").unwrap();

#[cfg(feature = "std_web")]
Expand All @@ -999,7 +1008,7 @@ mod tests {

#[test]
fn it_does_not_set_missing_class_name() {
let scope = AnyScope::default();
let scope = test_scope();
let parent = document().create_element("div").unwrap();

#[cfg(feature = "std_web")]
Expand All @@ -1016,7 +1025,7 @@ mod tests {

#[test]
fn it_sets_class_name() {
let scope = AnyScope::default();
let scope = test_scope();
let parent = document().create_element("div").unwrap();

#[cfg(feature = "std_web")]
Expand Down Expand Up @@ -1072,7 +1081,7 @@ mod tests {

#[test]
fn swap_order_of_classes() {
let scope = AnyScope::default();
let scope = test_scope();
let parent = document().create_element("div").unwrap();

#[cfg(feature = "std_web")]
Expand Down Expand Up @@ -1123,7 +1132,7 @@ mod tests {

#[test]
fn add_class_to_the_middle() {
let scope = AnyScope::default();
let scope = test_scope();
let parent = document().create_element("div").unwrap();

#[cfg(feature = "std_web")]
Expand Down

0 comments on commit 7586302

Please sign in to comment.