@@ -14,6 +14,40 @@ test('issuer.getBrand, brand.isMyIssuer', t => {
14
14
) ;
15
15
t . is ( issuer . getAllegedName ( ) , myBrand . getAllegedName ( ) ) ;
16
16
t . is ( issuer . getAllegedName ( ) , 'fungible' ) ;
17
+ t . is ( brand . getDisplayInfo ( ) , undefined ) ;
18
+ } ) ;
19
+
20
+ test ( 'brand.getDisplayInfo()' , t => {
21
+ const displayInfo = harden ( { decimalPlaces : 3 } ) ;
22
+ const { brand } = makeIssuerKit ( 'fungible' , MathKind . NAT , displayInfo ) ;
23
+ t . deepEqual ( brand . getDisplayInfo ( ) , displayInfo ) ;
24
+ const display = amount => {
25
+ const { brand : myBrand , value } = amount ;
26
+ const { decimalPlaces } = myBrand . getDisplayInfo ( ) ;
27
+ const valueDisplay = value . toString ( ) ;
28
+ const length = valueDisplay . length ;
29
+ return [
30
+ valueDisplay . slice ( 0 , length - decimalPlaces ) ,
31
+ '.' ,
32
+ valueDisplay . slice ( length - decimalPlaces ) ,
33
+ ] . join ( '' ) ;
34
+ } ;
35
+ t . is ( display ( { brand, value : 3000 } ) , '3.000' ) ;
36
+ } ) ;
37
+
38
+ test ( 'bad display info' , t => {
39
+ const displayInfo = harden ( { somethingUnexpected : 3 } ) ;
40
+ // @ts -ignore
41
+ t . throws ( ( ) => makeIssuerKit ( 'fungible' , MathKind . NAT , displayInfo ) , {
42
+ message :
43
+ 'key "somethingUnexpected" was not one of the expected keys ["decimalPlaces"]' ,
44
+ } ) ;
45
+ } ) ;
46
+
47
+ test ( 'empty display info' , t => {
48
+ const displayInfo = harden ( { } ) ;
49
+ const { brand } = makeIssuerKit ( 'fungible' , MathKind . NAT , displayInfo ) ;
50
+ t . deepEqual ( brand . getDisplayInfo ( ) , displayInfo ) ;
17
51
} ) ;
18
52
19
53
test ( 'amountMath from makeIssuerKit' , async t => {
@@ -117,7 +151,7 @@ test('purse.deposit', async t => {
117
151
. then ( checkDeposit ( fungible17 , fungibleSum ) ) ;
118
152
} ) ;
119
153
120
- test ( 'purse.deposit promise' , t => {
154
+ test ( 'purse.deposit promise' , async t => {
121
155
t . plan ( 1 ) ;
122
156
const { issuer, mint, amountMath } = makeIssuerKit ( 'fungible' ) ;
123
157
const fungible25 = amountMath . make ( 25 ) ;
@@ -126,7 +160,8 @@ test('purse.deposit promise', t => {
126
160
const payment = mint . mintPayment ( fungible25 ) ;
127
161
const exclusivePaymentP = E ( issuer ) . claim ( payment ) ;
128
162
129
- return t . throwsAsync (
163
+ await t . throwsAsync (
164
+ // @ts -ignore
130
165
( ) => E ( purse ) . deposit ( exclusivePaymentP , fungible25 ) ,
131
166
{ message : / d e p o s i t d o e s n o t a c c e p t p r o m i s e s / } ,
132
167
'failed to reject a promise for a payment' ,
@@ -198,11 +233,11 @@ test('issuer.claim', async t => {
198
233
} ) ;
199
234
} ) ;
200
235
201
- test ( 'issuer.splitMany bad amount' , t => {
236
+ test ( 'issuer.splitMany bad amount' , async t => {
202
237
const { mint, issuer, amountMath } = makeIssuerKit ( 'fungible' ) ;
203
238
const payment = mint . mintPayment ( amountMath . make ( 1000 ) ) ;
204
239
const badAmounts = Array ( 2 ) . fill ( amountMath . make ( 10 ) ) ;
205
- return t . throwsAsync (
240
+ await t . throwsAsync (
206
241
_ => E ( issuer ) . splitMany ( payment , badAmounts ) ,
207
242
{ message : / r i g h t s w e r e n o t c o n s e r v e d / } ,
208
243
'successfully throw if rights are not conserved in proposed new payments' ,
@@ -238,11 +273,11 @@ test('issuer.splitMany good amount', async t => {
238
273
. then ( checkPayments ) ;
239
274
} ) ;
240
275
241
- test ( 'issuer.split bad amount' , t => {
276
+ test ( 'issuer.split bad amount' , async t => {
242
277
const { mint, issuer, amountMath } = makeIssuerKit ( 'fungible' ) ;
243
278
const { amountMath : otherUnitOps } = makeIssuerKit ( 'other fungible' ) ;
244
279
const payment = mint . mintPayment ( amountMath . make ( 1000 ) ) ;
245
- return t . throwsAsync (
280
+ await t . throwsAsync (
246
281
_ => E ( issuer ) . split ( payment , otherUnitOps . make ( 10 ) ) ,
247
282
{
248
283
message : / t h e b r a n d i n t h e a l l e g e d A m o u n t i n ' c o e r c e ' d i d n ' t m a t c h t h e a m o u n t M a t h b r a n d / ,
@@ -343,7 +378,7 @@ test('issuer.combine bad payments', async t => {
343
378
const otherPayment = otherMint . mintPayment ( otherAmountMath . make ( 10 ) ) ;
344
379
payments . push ( otherPayment ) ;
345
380
346
- return t . throwsAsync (
381
+ await t . throwsAsync (
347
382
( ) => E ( issuer ) . combine ( payments ) ,
348
383
{ message : / " p a y m e n t " n o t f o u n d / } ,
349
384
'payment from other mint is not found' ,
0 commit comments