Skip to content

Commit

Permalink
test: move to wasm-bindgen unit test so we are now testing in web bro…
Browse files Browse the repository at this point in the history
…wser
  • Loading branch information
arn-the-long-beard committed Sep 23, 2020
1 parent 35e90de commit 82981a0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
25 changes: 15 additions & 10 deletions examples/custom_router/src/router/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ mod test {
use std::collections::HashMap;
use std::str::FromStr;
use strum::{EnumProperty, IntoEnumIterator};
use wasm_bindgen_test::*;

use super::*;

wasm_bindgen_test_configure!(run_in_browser);

#[derive(EnumIter, EnumString, EnumProperty, Display, Debug, Copy, Clone, PartialEq, Routes)]
#[strum(serialize_all = "snake_case")]
Expand Down Expand Up @@ -359,15 +364,15 @@ mod test {
#[strum(props(Default = "true"))]
NotFound,
}
#[test]
#[wasm_bindgen_test]
fn test_iteration() {
for route in ExampleRoutes::iter() {
// println!("the route is {:?}", route);
// println!("stuff {:?}", answer());
}
assert_eq!(ExampleRoutes::iter().len(), 6);
}
#[test]
#[wasm_bindgen_test]
fn test_root_routes_generation() {
let hashed_mapped_routes = ExampleRoutes::get_hashed_routes();
for map in &hashed_mapped_routes {
Expand All @@ -376,7 +381,7 @@ mod test {
let len: u8 = hashed_mapped_routes.len() as u8;
assert_eq!(len, 10);
}
#[test]
#[wasm_bindgen_test]
fn test_children_routes_generation() {
let hashed_mapped_routes = DashboardRoutes::get_hashed_routes();
for map in &hashed_mapped_routes {
Expand All @@ -385,7 +390,7 @@ mod test {
let len: u8 = hashed_mapped_routes.len() as u8;
assert_eq!(len, 4);
}
#[test]
#[wasm_bindgen_test]
fn test_great_children_routes_generation() {
let hashed_mapped_routes = DashboardAdminRoutes::get_hashed_routes();
for map in &hashed_mapped_routes {
Expand All @@ -395,7 +400,7 @@ mod test {
assert_eq!(len, 2);
}

#[test]
#[wasm_bindgen_test]
fn test_build_router() {
let router: Router<ExampleRoutes> = Router::new();
let routes = router.routes;
Expand All @@ -410,7 +415,7 @@ mod test {
assert_eq!(router.default_route, routes["not_found"])
}

#[test]
#[wasm_bindgen_test]
fn test_build_url() {
let router: Router<ExampleRoutes> = Router::new();
let url = router.base_url().clone().add_path_part("");
Expand All @@ -429,7 +434,7 @@ mod test {

assert_eq!(url_from_new.path(), url.path());
}
#[test]
#[wasm_bindgen_test]
fn test_navigation_to_route() {
let mut router: Router<ExampleRoutes> = Router::new();

Expand All @@ -455,7 +460,7 @@ mod test {
);
assert_eq!(router.current_history_index, 2);
}
#[test]
#[wasm_bindgen_test]
fn test_navigation_to_url() {
let mut router: Router<ExampleRoutes> = Router::new();

Expand All @@ -479,7 +484,7 @@ mod test {
);
assert_eq!(router.current_history_index, 2);
}
#[test]
#[wasm_bindgen_test]
fn test_backward() {
let mut router: Router<ExampleRoutes> = Router::new();

Expand Down Expand Up @@ -542,7 +547,7 @@ mod test {
);
}

#[test]
#[wasm_bindgen_test]
fn test_forward() {
let mut router: Router<ExampleRoutes> = Router::new();

Expand Down
4 changes: 0 additions & 4 deletions examples/custom_router/tests/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
#![cfg(target_arch = "wasm32")]

extern crate wasm_bindgen_test;
use client::route::Router;

use seed::Url;
use wasm_bindgen_test::*;
use web_sys::window;

extern crate client;

wasm_bindgen_test_configure!(run_in_browser);

#[wasm_bindgen_test]
Expand Down

0 comments on commit 82981a0

Please sign in to comment.