Skip to content

Commit 0849206

Browse files
committed
Update test
1 parent ffbe7cc commit 0849206

File tree

3 files changed

+141
-10
lines changed

3 files changed

+141
-10
lines changed

test/index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// import 'mocha';
1+
import 'mocha';
22
import notation from '../lib/index.js';
33
import assert from 'assert';
44

@@ -7,40 +7,52 @@ describe('Notation', () => {
77
const job = notation();
88
assert.ok(job);
99
});
10+
1011
it('Non-numeric should returned empty Object', () => {
1112
const job = notation('Non-numeric');
1213
assert.ok(job instanceof Object);
1314
});
15+
1416
it('1230 should returned ၁၂၃၀', () => {
1517
const job = notation('1230');
1618
assert.strictEqual('၁၂၃၀',job.number);
1719
});
20+
1821
it('၁၂၀၀,၀၀၀.၀ == 12000000 as removed decimals', () => {
1922
const job = notation('၁၂၀၀,၀၀၀.၀');
2023
assert.strictEqual('12000000',job.number);
2124
});
25+
2226
it('1.23e+5 == ၁၂၃၀၀၀', () => {
2327
const job = notation('1.23e+5');
2428
assert.strictEqual('၁၂၃၀၀၀',job.number);
2529
});
30+
2631
describe("var job = notation.get('12345678')", () => {
32+
2733
const job = notation('12345678');
2834
it('job.number:String should be ၁၂၃၄၅၆၇၈', () => {
2935
assert.strictEqual('၁၂၃၄၅၆၇၈',job.number);
3036
});
37+
3138
it('job.notation:Object should have 3 senses', () => {
3239
assert.ok(job.notation.length == 3);
3340
});
41+
3442
describe('each Sense', () => {
43+
3544
it(job.notation[0].sense, () => {
3645
assert.ok(job.notation[0].sense);
3746
});
47+
3848
it(job.notation[1].sense, () => {
3949
assert.ok(job.notation[1].sense);
4050
});
51+
4152
it(job.notation[2].sense, () => {
4253
assert.ok(job.notation[2].sense);
4354
});
55+
4456
});
4557
});
4658
});

test/mod.js

Lines changed: 114 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,123 @@
11
#!/usr/bin/env node
2+
// @ts-check
23
// NOTE: npm run package
3-
// const fs = require('fs');
4+
5+
import fs from 'fs';
6+
import notation from '../lib/index.js';
47
// // const notation = require('../notation');
58
// const notation = require('../');
6-
// let query = process.argv.slice(2)[0];
9+
let query = process.argv.slice(2)[0];
710

8-
// // query = '123456781234567876000';
9-
// // query = '27,000,000.00';
10-
// // query = '၁,၂၀၀၀၀၀.၂ဝ';
11+
query = '27,000,000.00';
12+
// query = '27,000,000';
13+
// query = '၁,၂၀၀၀၀၀.၂ဝ';
1114
// // query = '၂၇၀၀';
1215
// query = '၂,၇၀၀';
1316
// // query = '5.23e+8';
17+
// console.log(notation);
18+
19+
let raw = notation(query);
20+
fs.writeFile("./test/mod.json", JSON.stringify(raw, null, 2), 'utf8', e=>console.log(e || "...done"));
21+
22+
// function NumInWords( n ) {
23+
24+
// var string = n.toString(), units, tens, scales, start, end, chunks, chunksLen, chunk, ints, i, word, words, and = 'and';
25+
26+
// /* Remove spaces and commas */
27+
// string = string.replace(/[, ]/g,"");
28+
29+
// /* Is number zero? */
30+
// if( parseInt( string ) === 0 ) {
31+
// return 'zero';
32+
// }
33+
34+
// /* Array of units as words */
35+
// units = [ '', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen' ];
36+
37+
// /* Array of tens as words */
38+
// tens = [ '', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety' ];
39+
40+
// /* Array of scales as words */
41+
// scales = [ '', 'thousand', 'million', 'billion', 'trillion', 'quadrillion', 'quintillion', 'sextillion', 'septillion', 'octillion', 'nonillion', 'decillion', 'undecillion', 'duodecillion', 'tredecillion', 'quatttuor-decillion', 'quindecillion', 'sexdecillion', 'septen-decillion', 'octodecillion', 'novemdecillion', 'vigintillion', 'centillion' ];
42+
43+
// /* Split user argument into 3 digit chunks from right to left */
44+
// start = string.length;
45+
// chunks = [];
46+
// while( start > 0 ) {
47+
// end = start;
48+
// chunks.push( string.slice( ( start = Math.max( 0, start - 3 ) ), end ) );
49+
// }
50+
51+
// /* Check if function has enough scale words to be able to stringify the user argument */
52+
// chunksLen = chunks.length;
53+
// if( chunksLen > scales.length ) {
54+
// return '';
55+
// }
56+
57+
// /* Stringify each integer in each chunk */
58+
// words = [];
59+
// for( i = 0; i < chunksLen; i++ ) {
60+
61+
// chunk = parseInt( chunks[i] );
62+
63+
// if( chunk ) {
64+
65+
// /* Split chunk into array of individual integers */
66+
// ints = chunks[i].split( '' ).reverse().map( parseFloat );
67+
68+
// /* If tens integer is 1, i.e. 10, then add 10 to units integer */
69+
// if( ints[1] === 1 ) {
70+
// ints[0] += 10;
71+
// }
72+
73+
// /* Add scale word if chunk is not zero and array item exists */
74+
// if( ( word = scales[i] ) ) {
75+
// words.push( word );
76+
// }
77+
78+
// /* Add unit word if array item exists */
79+
// if( ( word = units[ ints[0] ] ) ) {
80+
// words.push( word );
81+
// }
82+
83+
// /* Add tens word if array item exists */
84+
// if( ( word = tens[ ints[1] ] ) ) {
85+
// words.push( word );
86+
// }
87+
88+
// /* Add 'and' string after units or tens integer if: */
89+
// if( ints[0] || ints[1] ) {
90+
91+
// /* Chunk has a hundreds integer or chunk is the first of multiple chunks */
92+
// if( ints[2] || (i + 1) > chunksLen ) {
93+
// words.push( and );
94+
// }
95+
96+
97+
// }
98+
99+
// /* Add hundreds word if array item exists */
100+
// if( ( word = units[ ints[2] ] ) ) {
101+
// words.push( word + ' hundred' );
102+
// }
103+
104+
// }
105+
106+
// }
107+
108+
// return words.reverse().join( ' ' );
109+
110+
// }
111+
112+
113+
// // console.log(NumInWords(1111))
114+
115+
// /**
116+
// * @param {number | string} n
117+
// */
118+
// function NumInMyanmar(n=''){
119+
// var string = n.toString().replace(/[, ]/g,"");
120+
// return string;
121+
// }
14122

15-
// let raw = notation.get(query);
16-
// fs.writeFile("./test/mod.json", JSON.stringify(raw, null, 2), 'utf8', e=>console.log(e || "...done"));
123+
// console.log(NumInMyanmar(1111))

test/mod.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
{
2-
"number": "2700",
2+
"number": "၂၇၀၀၀၀၀၀",
33
"notation": [
44
{
5-
"sense": "နှစ်ထောင်နှင့်ခုနစ်ရာ"
5+
"sense": "သိန်းပေါင်း နှစ်ရာ့ခုနစ်ဆယ်",
6+
"exam": {
7+
"test": 2
8+
}
9+
},
10+
{
11+
"sense": "သန်းပေါင်း နှစ်ဆယ့်ခုနစ်",
12+
"exam": {
13+
"test": 2
14+
}
15+
},
16+
{
17+
"sense": "နှစ်ကု​ဋေ​နှင့် ခုနစ်သန်း"
618
}
719
]
820
}

0 commit comments

Comments
 (0)