1
1
import { expect } from 'chai' ;
2
+ import { bignumber , complex , evaluate , fraction , matrix , range , unit } from 'mathjs' ;
2
3
3
4
import { clamp , formatResult , ResultFormatOptions } from '../../src/utils/Math' ;
4
5
@@ -59,7 +60,11 @@ describe('math utils', () => {
59
60
}
60
61
} ) ;
61
62
62
- it ( 'should format date results' ) ;
63
+ it ( 'should format date results' , ( ) => {
64
+ const d = new Date ( ) ;
65
+ expect ( formatResult ( d , TEST_SCOPE , TEST_OPTIONS ) ) . to . include ( d . getFullYear ( ) ) ;
66
+ } ) ;
67
+
63
68
it ( 'should recursive over array results' , ( ) => {
64
69
expect ( formatResult ( [ ] , TEST_SCOPE , TEST_OPTIONS ) ) . to . equal ( '' ) ;
65
70
expect ( formatResult ( [ true , false ] , TEST_SCOPE , TEST_OPTIONS ) ) . to . equal ( 'true,false' ) ;
@@ -77,8 +82,19 @@ describe('math utils', () => {
77
82
expect ( formatResult ( / f o o / , TEST_SCOPE , TEST_OPTIONS ) ) . to . equal ( 'regexp' ) ;
78
83
} ) ;
79
84
80
- it ( 'should format math results' ) ;
81
- it ( 'should format math result sets' ) ;
85
+ it ( 'should format math results' , ( ) => {
86
+ expect ( formatResult ( bignumber ( 3 ) , TEST_SCOPE , TEST_OPTIONS ) ) . to . equal ( '3' ) ;
87
+ expect ( formatResult ( complex ( 3 , - 2 ) , TEST_SCOPE , TEST_OPTIONS ) ) . to . equal ( '3 - 2i' ) ;
88
+ expect ( formatResult ( fraction ( 1 , 3 ) , TEST_SCOPE , TEST_OPTIONS ) ) . to . equal ( '1/3' ) ;
89
+ expect ( formatResult ( matrix ( [ [ 1 , 2 ] , [ 3 , 4 ] ] ) , TEST_SCOPE , TEST_OPTIONS ) ) . to . equal ( '[[1, 2], [3, 4]]' ) ;
90
+ expect ( formatResult ( range ( 1 , 4 ) , TEST_SCOPE , TEST_OPTIONS ) ) . to . equal ( '[1, 2, 3]' ) ;
91
+ expect ( formatResult ( unit ( 10 , 'm' ) , TEST_SCOPE , TEST_OPTIONS ) ) . to . equal ( '10 m' ) ;
92
+ } ) ;
93
+
94
+ it ( 'should format math result sets' , ( ) => {
95
+ expect ( formatResult ( evaluate ( '1+1 \n 2+2' ) , TEST_SCOPE , TEST_OPTIONS ) ) . to . equal ( '2,4' ) ;
96
+ } ) ;
97
+
82
98
it ( 'should format math nodes' ) ;
83
99
} ) ;
84
100
} ) ;
0 commit comments