Skip to content

Commit

Permalink
adapt to the yew new version 0.15 and improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
spielcrypto committed Apr 26, 2020
1 parent c80f102 commit b728f22
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 31 deletions.
31 changes: 31 additions & 0 deletions crate/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions crate/yew_prism/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@ crate-type = ["cdylib", "rlib"]
yew = { version = "0.15", features = ["toml", "yaml", "msgpack", "cbor", "web_sys"]}
wasm-bindgen="0.2"
web-sys={version="0.3"}

[dev-dependencies]
wasm-bindgen-test = "0.3"
26 changes: 26 additions & 0 deletions crate/yew_prism/src/prism.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::prism_sys::{highlight, languages as lang};
use wasm_bindgen_test::*;
use web_sys::HtmlElement;
use yew::prelude::*;

Expand Down Expand Up @@ -59,3 +60,28 @@ impl Component for Prism {
}
}
}

wasm_bindgen_test_configure!(run_in_browser);

#[wasm_bindgen_test]
fn shoud_create_prism_component() {
let props_prism = Props {
code: "let greeting: &str = \"Hello World\";".to_string(),
language: "rust".to_string(),
};

let link = ComponentLink::new();

let prism = Prism::create(props_prism, link);

let prism_vnode = prism.render();
let code_ref = NodeRef::default();

let vnode_expected = html! {
<pre>
<code class="language-rust", ref=code_ref/>
</pre>
};

assert_eq!(prism_vnode, vnode_expected);
}
28 changes: 0 additions & 28 deletions crate/yew_prism/tests/prism.rs

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"url": "https://github.com/spielrs/yew-parcel-template"
},
"name": "yew-prism",
"version": "0.1.0",
"version": "0.2.0",
"license": "Apache-2.0/MIT",
"scripts": {
"start": "parcel index.html",
Expand Down

0 comments on commit b728f22

Please sign in to comment.