Skip to content

Commit

Permalink
Fixes to wasm test
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Jun 6, 2023
1 parent 92a5ec5 commit b546e71
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tests/wasm.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
//! Run this test with:
//! `env TZ="$(date +%z)" NOW="$(date +%s)" wasm-pack test --node -- --features wasmbind`
//!
//! It will fail if the local timezone does not match one of the timezones defined below.

#![cfg(all(
target_arch = "wasm32",
feature = "wasmbind",
not(any(target_os = "emscripten", target_os = "wasi"))
))]

use self::chrono::prelude::*;
use self::wasm_bindgen_test::*;
use chrono::prelude::*;
use wasm_bindgen_test::*;

#[wasm_bindgen_test]
fn now() {
Expand Down Expand Up @@ -52,7 +57,7 @@ fn from_is_exact() {

let dt = DateTime::<Utc>::from(now.clone());

assert_eq!(now.get_time() as i64, dt.timestamp_millis_opt().unwrap());
assert_eq!(now.get_time() as i64, dt.timestamp_millis());
}

#[wasm_bindgen_test]
Expand All @@ -72,7 +77,7 @@ fn convert_all_parts_with_milliseconds() {
let js_date = js_sys::Date::from(time);

assert_eq!(js_date.get_utc_full_year(), 2020);
assert_eq!(js_date.get_utc_month(), 12);
assert_eq!(js_date.get_utc_month(), 11); // months are numbered 0..=11
assert_eq!(js_date.get_utc_date(), 1);
assert_eq!(js_date.get_utc_hours(), 3);
assert_eq!(js_date.get_utc_minutes(), 1);
Expand Down

0 comments on commit b546e71

Please sign in to comment.