@@ -141,32 +141,36 @@ describe('UNIT: BigNumber matchers', () => {
141
141
142
142
describe ( 'closeTo' , ( ) => {
143
143
it ( '.to.be.closeTo' , ( ) => {
144
- expect ( BigNumber . from ( 100 ) ) . to . be . closeTo ( BigNumber . from ( 101 ) , 10 ) ;
145
- expect ( BigNumber . from ( 100 ) ) . to . be . closeTo ( BigNumber . from ( 101 ) , BigNumber . from ( 10 ) ) ;
144
+ checkAll ( 100 , 101 , ( a , b ) => expect ( a ) . to . be . closeTo ( b , 10 ) ) ;
145
+ checkAll ( 100 , 101 , ( a , b ) => expect ( a ) . to . be . closeTo ( b , BigNumber . from ( 10 ) ) ) ;
146
146
} ) ;
147
147
148
148
it ( '.not.to.be.closeTo' , ( ) => {
149
- expect ( BigNumber . from ( 100 ) ) . not . to . be . closeTo ( BigNumber . from ( 111 ) , 10 ) ;
150
- expect ( BigNumber . from ( 100 ) ) . not . to . be . closeTo ( BigNumber . from ( 111 ) , BigNumber . from ( 10 ) ) ;
149
+ checkAll ( 100 , 111 , ( a , b ) => expect ( a ) . not . to . be . closeTo ( b , 10 ) ) ;
150
+ checkAll ( 100 , 111 , ( a , b ) => expect ( a ) . not . to . be . closeTo ( b , BigNumber . from ( 10 ) ) ) ;
151
151
} ) ;
152
152
153
153
it ( 'expect to throw on error' , ( ) => {
154
- expect ( ( ) => expect ( BigNumber . from ( 100 ) ) . to . be . closeTo ( BigNumber . from ( 111 ) , 10 ) ) . to . throw (
155
- AssertionError ,
156
- 'Expected "100" to be within 10 of 111'
157
- ) ;
158
- expect ( ( ) => expect ( BigNumber . from ( 100 ) ) . to . be . closeTo ( BigNumber . from ( 111 ) , BigNumber . from ( 10 ) ) ) . to . throw (
159
- AssertionError ,
160
- 'Expected "100" to be within 10 of 111'
161
- ) ;
162
- expect ( ( ) => expect ( BigNumber . from ( 100 ) ) . not . to . be . closeTo ( BigNumber . from ( 101 ) , 10 ) ) . to . throw (
163
- AssertionError ,
164
- 'Expected "100" NOT to be within 10 of 101'
165
- ) ;
166
- expect ( ( ) => expect ( BigNumber . from ( 100 ) ) . not . to . be . closeTo ( BigNumber . from ( 101 ) , BigNumber . from ( 10 ) ) ) . to . throw (
167
- AssertionError ,
168
- 'Expected "100" NOT to be within 10 of 101'
169
- ) ;
154
+ checkAll ( 100 , 111 , ( a , b ) => {
155
+ expect ( ( ) => expect ( BigNumber . from ( a ) ) . to . be . closeTo ( BigNumber . from ( b ) , 10 ) ) . to . throw (
156
+ AssertionError ,
157
+ 'Expected "100" to be within 10 of 111'
158
+ ) ;
159
+ expect ( ( ) => expect ( BigNumber . from ( a ) ) . to . be . closeTo ( BigNumber . from ( b ) , BigNumber . from ( 10 ) ) ) . to . throw (
160
+ AssertionError ,
161
+ 'Expected "100" to be within 10 of 111'
162
+ ) ;
163
+ } ) ;
164
+ checkAll ( 100 , 101 , ( a , b ) => {
165
+ expect ( ( ) => expect ( BigNumber . from ( a ) ) . not . to . be . closeTo ( BigNumber . from ( b ) , 10 ) ) . to . throw (
166
+ AssertionError ,
167
+ 'Expected "100" NOT to be within 10 of 101'
168
+ ) ;
169
+ expect ( ( ) => expect ( BigNumber . from ( a ) ) . not . to . be . closeTo ( BigNumber . from ( b ) , BigNumber . from ( 10 ) ) ) . to . throw (
170
+ AssertionError ,
171
+ 'Expected "100" NOT to be within 10 of 101'
172
+ ) ;
173
+ } ) ;
170
174
} ) ;
171
175
} ) ;
172
176
} ) ;
0 commit comments