diff options
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Tests/builtins/Intl/DisplayNames/DisplayNames.prototype.of.js | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp index 598c9c4dad..25db52094f 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp @@ -86,6 +86,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of) result = Unicode::get_locale_script_mapping(display_names->locale(), code.as_string().string()); break; case DisplayNames::Type::Currency: + result = Unicode::get_locale_currency_mapping(display_names->locale(), code.as_string().string()); break; default: VERIFY_NOT_REACHED(); diff --git a/Userland/Libraries/LibJS/Tests/builtins/Intl/DisplayNames/DisplayNames.prototype.of.js b/Userland/Libraries/LibJS/Tests/builtins/Intl/DisplayNames/DisplayNames.prototype.of.js index 7b2385ab2e..924369b8bf 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Intl/DisplayNames/DisplayNames.prototype.of.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Intl/DisplayNames/DisplayNames.prototype.of.js @@ -73,4 +73,19 @@ describe("correct behavior", () => { expect(es419.of("Aaaa")).toBe("Aaaa"); expect(zhHant.of("Aaaa")).toBe("Aaaa"); }); + + test("option type currency", () => { + const en = new Intl.DisplayNames("en", { type: "currency" }); + expect(en.of("USD")).toBe("US Dollar"); + + const es419 = new Intl.DisplayNames("es-419", { type: "currency" }); + expect(es419.of("USD")).toBe("dรณlar estadounidense"); + + const zhHant = new Intl.DisplayNames(["zh-Hant"], { type: "currency" }); + expect(zhHant.of("USD")).toBe("็พๅ
"); + + expect(en.of("AAA")).toBe("AAA"); + expect(es419.of("AAA")).toBe("AAA"); + expect(zhHant.of("AAA")).toBe("AAA"); + }); }); |