From 54523d82eda1bc38e02c1db7dadabb7f419eb02c Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 3 Jul 2018 14:37:38 +0200 Subject: [PATCH 1/2] test(js) Fix expectations regarding given locales. --- tests/all/js_globals/Date.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/all/js_globals/Date.rs b/tests/all/js_globals/Date.rs index 6a8a66f1f..e1ff7c854 100644 --- a/tests/all/js_globals/Date.rs +++ b/tests/all/js_globals/Date.rs @@ -160,7 +160,7 @@ fn to_locale_date_string() { let date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0)); let options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }; - assert.equal(wasm.to_locale_date_string(date, 'de-DE', options), 'Thursday, December 20, 2012'); + assert.equal(wasm.to_locale_date_string(date, 'de-DE', options), 'Donnerstag, 20. Dezember 2012'); } "#) .test() @@ -188,7 +188,7 @@ fn to_locale_string() { export function test() { let date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0)); - assert.equal(wasm.to_locale_string(date, 'en-GB', { timeZone: 'UTC' }), "12/20/2012, 3:00:00 AM"); + assert.equal(wasm.to_locale_string(date, 'en-GB', { timeZone: 'UTC' }), "20/12/2012, 03:00:00"); } "#) .test() From f5d4751c0bb058f6f3fde81c36b591529621e5ff Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 4 Jul 2018 16:47:51 +0200 Subject: [PATCH 2/2] test(js) Check the types and lightly the data, but not that much. Because NodeJS can have different i18n behaviors depending of the version, let's keep things simple. In this case, we want to test the types, period. Cf. https://github.com/rustwasm/wasm-bindgen/pull/374#issuecomment-402447333 --- tests/all/js_globals/Date.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/all/js_globals/Date.rs b/tests/all/js_globals/Date.rs index e1ff7c854..24fa62007 100644 --- a/tests/all/js_globals/Date.rs +++ b/tests/all/js_globals/Date.rs @@ -160,7 +160,9 @@ fn to_locale_date_string() { let date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0)); let options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }; - assert.equal(wasm.to_locale_date_string(date, 'de-DE', options), 'Donnerstag, 20. Dezember 2012'); + let output = wasm.to_locale_date_string(date, 'de-DE', options) + assert.equal(typeof output, 'string'); + assert.ok(output.length > 0); } "#) .test() @@ -188,7 +190,9 @@ fn to_locale_string() { export function test() { let date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0)); - assert.equal(wasm.to_locale_string(date, 'en-GB', { timeZone: 'UTC' }), "20/12/2012, 03:00:00"); + let output = wasm.to_locale_string(date, 'en-GB', { timeZone: 'UTC' }); + assert.equal(typeof output, 'string'); + assert.ok(output.length > 0); } "#) .test()