@@ -224,6 +224,89 @@ describe("written-number", function() {
224224 } ) ;
225225 } ) ;
226226
227+ describe ( "writtenNumber(n, { lang: 'ptPT', ... })" , function ( ) {
228+ before ( function ( ) {
229+ writtenNumber . defaults . lang = "ptPT" ;
230+ } ) ;
231+
232+ it ( "gets exposed" , function ( ) {
233+ should . exist ( writtenNumber ) ;
234+ writtenNumber . should . be . instanceof ( Function ) ;
235+ } ) ;
236+
237+ it ( "correctly converts numbers < 10" , function ( ) {
238+ writtenNumber ( 3 ) . should . equal ( "três" ) ;
239+ writtenNumber ( 8 ) . should . equal ( "oito" ) ;
240+ } ) ;
241+
242+ it ( "correctly converts numbers < 20" , function ( ) {
243+ writtenNumber ( 13 ) . should . equal ( "treze" ) ;
244+ writtenNumber ( 19 ) . should . equal ( "dezanove" ) ;
245+ } ) ;
246+
247+ it ( "correctly converts numbers < 100" , function ( ) {
248+ writtenNumber ( 20 ) . should . equal ( "vinte" ) ;
249+ writtenNumber ( 25 ) . should . equal ( "vinte e cinco" ) ;
250+ writtenNumber ( 88 ) . should . equal ( "oitenta e oito" ) ;
251+ writtenNumber ( 73 ) . should . equal ( "setenta e três" ) ;
252+ } ) ;
253+
254+ it ( "correctly converts numbers < 1000" , function ( ) {
255+ writtenNumber ( 144 ) . should . equal ( "cento e quarenta e quatro" ) ;
256+ writtenNumber ( 200 ) . should . equal ( "duzentos" ) ;
257+ writtenNumber ( 1234 ) . should . equal ( "mil duzentos e trinta e quatro" ) ;
258+ writtenNumber ( 4323 ) . should . equal ( "quatro mil trezentos e vinte e três" ) ;
259+ writtenNumber ( 242 ) . should . equal ( "duzentos e quarenta e dois" ) ;
260+ } ) ;
261+
262+ it ( "correctly converts numbers > 1000" , function ( ) {
263+ writtenNumber ( 4323000 ) . should . equal (
264+ "quatro milhões trezentos e vinte e três mil"
265+ ) ;
266+ writtenNumber ( 4323055 ) . should . equal (
267+ "quatro milhões trezentos e vinte e três mil e cinquenta e cinco"
268+ ) ;
269+ writtenNumber ( 1570025 ) . should . equal (
270+ "um milhão quinhentos e setenta mil e vinte e cinco"
271+ ) ;
272+ } ) ;
273+
274+ it ( "works for 14101 (https://github.com/yamadapc/js-written-number/issues/38)" , function ( ) {
275+ writtenNumber ( 14101 ) . should . equal ( "catorze mil cento e um" ) ;
276+ } ) ;
277+
278+ it ( "works for 14201 (https://github.com/yamadapc/js-written-number/issues/38)" , function ( ) {
279+ writtenNumber ( 14201 ) . should . equal ( "catorze mil duzentos e um" ) ;
280+ } ) ;
281+
282+ it ( "works for 1001000 (https://github.com/yamadapc/js-written-number/issues/38)" , function ( ) {
283+ writtenNumber ( 1001000 ) . should . equal ( "um milhão e mil" ) ;
284+ } ) ;
285+
286+ it ( "works for 1001200 (https://github.com/yamadapc/js-written-number/issues/38)" , function ( ) {
287+ writtenNumber ( 1001200 ) . should . equal ( "um milhão mil e duzentos" ) ;
288+ } ) ;
289+
290+ it ( "works for 14200 (https://github.com/yamadapc/js-written-number/issues/38)" , function ( ) {
291+ writtenNumber ( 14200 ) . should . equal ( "catorze mil e duzentos" ) ;
292+ } ) ;
293+
294+ it ( "works for 14100 (https://github.com/yamadapc/js-written-number/issues/38)" , function ( ) {
295+ writtenNumber ( 14100 ) . should . equal ( "catorze mil e cem" ) ;
296+ } ) ;
297+
298+ it ( "correctly converts numbers > 1 000 000 000" , function ( ) {
299+ writtenNumber ( 1000000000 ) . should . equal ( "mil milhões" ) ;
300+ writtenNumber ( 2580000000 ) . should . equal (
301+ "dois mil quinhentos e oitenta milhões"
302+ ) ;
303+ writtenNumber ( 1000000000000000 ) . should . equal ( "mil biliões" ) ;
304+ writtenNumber ( 3627000000000 ) . should . equal (
305+ "três biliões seiscentos e vinte e sete mil milhões"
306+ ) ;
307+ } ) ;
308+ } ) ;
309+
227310 describe ( "writtenNumber(n, { lang: 'fr', ... })" , function ( ) {
228311 before ( function ( ) {
229312 writtenNumber . defaults . lang = "fr" ;
0 commit comments