Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

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 committed May 17, 2019
1 parent 94abd75 commit 1087401
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
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 src/en.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// GENERATED FILE
export default {"locale":"en"};
export default { locale: "en" };
20 changes: 20 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
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"
);
});
});
2 changes: 1 addition & 1 deletion tests/runner.js
Original file line number Diff line number Diff line change
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 1087401

Please sign in to comment.