This repository was archived by the owner on Feb 23, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -33,12 +33,12 @@ class SettingAction {
3333 * perist the updated settings to disk.
3434 * @param {string } options.fiat The fiat currency e.g. `usd`
3535 */
36- setFiatCurrency ( { fiat } ) {
36+ async setFiatCurrency ( { fiat } ) {
3737 if ( ! FIATS [ fiat ] ) {
3838 throw new Error ( `Invalid fiat currency: ${ fiat } ` ) ;
3939 }
4040 this . _store . settings . fiat = fiat ;
41- this . _wallet . getExchangeRate ( ) ;
41+ await this . _wallet . getExchangeRate ( ) ;
4242 this . _db . save ( ) ;
4343 }
4444
@@ -59,7 +59,7 @@ class SettingAction {
5959 try {
6060 let locale = await this . _ipc . send ( 'locale-get' , 'locale' ) ;
6161 const fiat = localeCurrency . getCurrency ( locale ) . toLowerCase ( ) ;
62- this . setFiatCurrency ( { fiat } ) ;
62+ await this . setFiatCurrency ( { fiat } ) ;
6363 } catch ( err ) {
6464 log . error ( 'Detecting local currency failed' , err ) ;
6565 }
Original file line number Diff line number Diff line change @@ -44,17 +44,17 @@ describe('Action Setting Unit Test', () => {
4444 } ) ;
4545
4646 describe ( 'setFiatCurrency()' , ( ) => {
47- it ( 'should set a valid fiat currency and save settings' , ( ) => {
48- setting . setFiatCurrency ( { fiat : 'eur' } ) ;
47+ it ( 'should set a valid fiat currency and save settings' , async ( ) => {
48+ await setting . setFiatCurrency ( { fiat : 'eur' } ) ;
4949 expect ( store . settings . fiat , 'to equal' , 'eur' ) ;
5050 expect ( wallet . getExchangeRate , 'was called once' ) ;
5151 expect ( db . save , 'was called once' ) ;
5252 } ) ;
5353
54- it ( 'should throw error on invalid fiat type' , ( ) => {
55- expect (
56- setting . setFiatCurrency . bind ( null , { fiat : 'invalid' } ) ,
57- 'to throw ' ,
54+ it ( 'should throw error on invalid fiat type' , async ( ) => {
55+ await expect (
56+ setting . setFiatCurrency ( { fiat : 'invalid' } ) ,
57+ 'to be rejected with error satisfying ' ,
5858 / I n v a l i d /
5959 ) ;
6060 } ) ;
You can’t perform that action at this time.
0 commit comments