Skip to content

Commit

Permalink
add tests for custom format, fixes #158
Browse files Browse the repository at this point in the history
  • Loading branch information
Long Ho authored and longlho committed Apr 26, 2020
1 parent 10fd70d commit 7b4a9e1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/formatjs/packages/intl-messageformat/package.json
Expand Up @@ -15,9 +15,10 @@
],
"author": "Eric Ferraiuolo <eferraiuolo@gmail.com>",
"contributors": [
"Drew Folta <drew@folta.net>",
"Anthony Pipkin <a.pipkin@yahoo.com>",
"Caridy Patino <caridy@gmail.com>",
"Anthony Pipkin <a.pipkin@yahoo.com>"
"Drew Folta <drew@folta.net>",
"Long Ho <holevietlong@gmail.com"
],
"bugs": {
"url": "https://github.com/formatjs/intl-messageformat/issues"
Expand Down
2 changes: 1 addition & 1 deletion packages/formatjs/packages/intl-messageformat/src/en.js
@@ -1,2 +1,2 @@
// GENERATED FILE
export default {"locale":"en"};
export default { locale: "en" };
20 changes: 20 additions & 0 deletions packages/formatjs/packages/intl-messageformat/tests/index.js
Expand Up @@ -447,4 +447,24 @@ describe("IntlMessageFormat", function() {
expect(ptMZ.format({ num: 100 })).to.equal("other");
});
});

it("custom formats should work", function() {
var msg = "Today is {time, date, verbose}";
var mf = new IntlMessageFormat(msg, "pt", {
date: {
verbose: {
month: "long",
day: "numeric",
year: "numeric",
hour: "numeric",
minute: "numeric",
second: "numeric",
timeZoneName: "short"
}
}
});
expect(mf.format({ time: 0 })).to.contain(
"Today is 31 de dezembro de 1969 19:00:00"
);
});
});
Expand Up @@ -2,7 +2,7 @@ if (typeof Intl === "undefined") {
require("intl");
}

require('intl-pluralrules')
require("intl-pluralrules");

global.expect = require("expect.js");
global.IntlMessageFormat = require("../");
Expand Down

0 comments on commit 7b4a9e1

Please sign in to comment.