[gjs] tests: Adapt to new Date.toLocaleDateString()



commit 169e8793851606f46d9c9448c1b2a12ebe767f8b
Author: Philip Chimento <philip endlessm com>
Date:   Tue Nov 8 16:26:20 2016 -0800

    tests: Adapt to new Date.toLocaleDateString()
    
    This does not take a format string any longer, but instead locale and
    options parameters [1]. Now that it is possible to specify the locale, we
    can make this test into one with deterministic results.
    
    [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751252

 installed-tests/js/testLocale.js |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/installed-tests/js/testLocale.js b/installed-tests/js/testLocale.js
index e50d0c2..213197c 100644
--- a/installed-tests/js/testLocale.js
+++ b/installed-tests/js/testLocale.js
@@ -2,12 +2,10 @@
 const JSUnit = imports.jsUnit;
 
 function testToLocaleDateString() {
-    let date = new Date();
-    // %A is the weekday name, this tests locale_to_unicode
-    // we're basically just testing for a non-crash, since
-    // we'd have to run in a specific locale to have any
-    // idea about the result.
-    date.toLocaleDateString("%A");
+    let date = new Date('12/15/1981');
+    // Requesting the weekday name tests locale_to_unicode
+    let datestr = date.toLocaleDateString('pt-BR', { weekday: 'long' });
+    JSUnit.assertEquals('terça-feira', datestr);
 }
 
 function testToLocaleLowerCase() {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]