Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

Commit 0aa4f48

Browse files
committed
build, fix for linting and adding new tests for #190
1 parent b70852b commit 0aa4f48

7 files changed

+122
-22
lines changed

dist/Intl.complete.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/Intl.js

+76-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/Intl.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/Intl.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/Intl.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"devDependencies": {
1414
"async": "^0.9.0",
1515
"babel-cli": "^6.2.0",
16-
"babel-eslint": "^5.0.0",
16+
"babel-eslint": "^6.1.2",
1717
"babel-plugin-transform-es2015-modules-commonjs": "^6.4.0",
1818
"babel-plugin-transform-es3-member-expression-literals": "^6.3.13",
1919
"babel-plugin-transform-es3-property-literals": "^6.3.13",

tests/sanity.js

+39-9
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ function assert(value, expected, message) {
1010
}
1111
}
1212

13-
function newDateUTC() {
14-
var date = new Date(...arguments)
13+
function newDateUTC(str) {
14+
var date = new Date(str);
1515
var localTime = date.getTime();
1616
var localOffset = date.getTimezoneOffset() * 60000;
1717
var utc = localTime + localOffset;
@@ -26,7 +26,7 @@ assert(new IntlPolyfill.NumberFormat('de-DE', {
2626
assert(new IntlPolyfill.NumberFormat('en-US', {
2727
style: 'currency',
2828
currency: 'GBP',
29-
minimumFractionDigits: 2,
29+
minimumFractionDigits: 2
3030
}).format(59.88), '£59.88', 'currency with fragtional digits');
3131

3232
assert(new IntlPolyfill.DateTimeFormat('en', {
@@ -51,12 +51,7 @@ assert(new IntlPolyfill.DateTimeFormat('en-GB', {
5151
assert(new IntlPolyfill.DateTimeFormat('en', {
5252
month:'long',
5353
year: 'numeric'
54-
}).format(new Date('2016/01/16')), 'January 2016', 'month should be long');
55-
56-
// Issues #190, #192
57-
assert(new IntlPolyfill.DateTimeFormat('en-us', {
58-
month:'long',
59-
}).format(new Date(2016, 0, 1)), 'January', 'month should be long');
54+
}).format(new Date('2016/01/16')), 'January 2016', 'month and year should be long');
6055

6156
// issue #196
6257
/a*$/.exec('b' + new Array(32768 + 1).join('a'));
@@ -68,3 +63,38 @@ assert(RegExp.leftContext, leftContext, 'RegExp.leftContext restored');
6863
assert(RegExp.input, input, 'RegExp.input restored');
6964
assert(RegExp.lastMatch, lastMatch, 'RegExp.lastMatch restored');
7065
'a'.match(/a/);
66+
67+
// Issues #190, #192
68+
assert(new IntlPolyfill.DateTimeFormat('en-us', {
69+
month: 'long'
70+
}).format(new Date(2016, 0, 1)), 'January', 'single month should be long');
71+
72+
assert(new IntlPolyfill.DateTimeFormat('en-us', {
73+
day: '2-digit'
74+
}).format(new Date(2016, 0, 1)), '01', 'single day should be 2-digit');
75+
76+
assert(new IntlPolyfill.DateTimeFormat('en-us', {
77+
year: '2-digit'
78+
}).format(new Date(2016, 0, 1)), '16', 'single year should be 2-digit');
79+
80+
assert(new IntlPolyfill.DateTimeFormat('en-us', {
81+
weekday: 'short'
82+
}).format(new Date(2016, 0, 1)), 'Fri', 'single weekday should be short');
83+
84+
assert(new IntlPolyfill.DateTimeFormat('en-us', {
85+
minute: '2-digit'
86+
}).format(new Date(2016, 0, 1)), '00', 'single minute should be 2-digit');
87+
88+
assert(new IntlPolyfill.DateTimeFormat('en-us', {
89+
second: '2-digit'
90+
}).format(new Date(2016, 0, 1)), '00', 'single second should be 2-digit');
91+
92+
// alternative, hour can't alway produce a single digit, because of ampm, but
93+
// this case should be cover by CLDR availableFormats
94+
assert(new IntlPolyfill.DateTimeFormat('en-us', {
95+
hour: 'numeric'
96+
}).format(new Date(2016, 0, 1, 6)), '6 AM', 'single second should be 2-digit');
97+
98+
assert(new IntlPolyfill.DateTimeFormat('en-GB', {
99+
hour: 'numeric'
100+
}).format(new Date(2016, 0, 1, 6)), '6', 'single second should be 2-digit');

0 commit comments

Comments
 (0)