diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index cc0f480..54e5262 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -29,11 +29,13 @@ jobs:
- name: install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- - name: check
- run: cargo check
+ - run: cargo check
- - name: test
- run: wasm-pack test --node
+ - run: cargo test
+
+ - run: wasm-pack test --headless --firefox
+
+ - run: wasm-pack test --headless --chrome
build:
runs-on: ubuntu-latest
diff --git a/tests/web.rs b/tests/web.rs
index de5c1da..70ee958 100644
--- a/tests/web.rs
+++ b/tests/web.rs
@@ -8,6 +8,86 @@ use wasm_bindgen_test::*;
wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen_test]
-fn pass() {
- assert_eq!(1 + 1, 2);
+fn basic_merge() {
+ // arrange
+ let array: js_sys::Array = js_sys::Array::new();
+ let file1 = wasm_bindgen::JsValue::from_str(
+ "
+
+
+ file1 tracks
+ 1
+
+
+ 2152.8
+
+
+
+
+ ",
+ );
+ let file2 = wasm_bindgen::JsValue::from_str(
+ "
+
+
+ file2 tracks
+ 1
+
+
+ 2556.8
+
+
+
+
+ ",
+ );
+ array.push(&file1);
+ array.push(&file2);
+
+ let exp = wasm_bindgen::JsValue::from_str(
+ "
+
+
+ merged
+
+
+
+
+
+ file1 tracks
+ 1
+
+
+ 2152.8
+
+
+
+
+
+ file2 tracks
+ 1
+
+
+ 2556.8
+
+
+
+
+
+",
+ );
+
+ // act
+ let obs = gpx_web_utils::merge(array);
+
+ // assert
+ assert_eq!(obs, exp);
}
+
+// TODO: https://github.com/rustwasm/wasm-bindgen/issues/2286
+// #[wasm_bindgen_test]
+// #[should_panic]
+// fn invalid_inputs() {
+// let array: js_sys::Array = js_sys::Array::new_with_length(10);
+// let obs = gpx_web_utils::merge(array);
+// }