Created
February 5, 2014 20:52
-
-
Save drewfish/8832805 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('for intlMessage', function () { | |
var tmpl = '{@intl formats=intl.formats}{@intlMessage _msg=MSG product=PRODUCT price=PRICE deadline=DEADLINE timeZone=TZ/}{/intl}', | |
ctx = { | |
MSG: '{product} cost {price, usd} (or {price, eur}) if ordered by {deadline, date, medium}', | |
intl: { | |
formats: { | |
eur: function(val, locale, options) { | |
return new intl.NumberFormat(locale, { | |
style: 'currency', | |
currency: 'EUR' | |
}).format(val); | |
}, | |
usd: function(val, locale, options) { | |
return new intl.NumberFormat(locale, { | |
style: 'currency', | |
currency: 'USD' | |
}).format(val); | |
}, | |
ymd: function(val, locale, options) { | |
return new intl.DateTimeFormat(locale, { | |
year: 'numeric', | |
month: 'numeric', | |
day: 'numeric' | |
}).format(val); | |
} | |
} | |
}, | |
PRODUCT: 'oranges', | |
PRICE: 40000.004, | |
DEADLINE: timeStamp, | |
TZ: 'UTC' | |
}, | |
expected = "oranges cost $40,000.00 (or €40,000.00) if ordered by Jan 23, 2014"; | |
Dust.renderSource(tmpl, ctx, function(err, out) { | |
expect(out).to.equal(expected); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment