-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1297 from LiskHQ/1293-move-api-calls-from-compone…
…nt-level Move newsFeed API call to actions - Closes #1293
- Loading branch information
Showing
16 changed files
with
173 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,31 @@ | ||
import { expect } from 'chai'; | ||
import sinon from 'sinon'; | ||
import React from 'react'; | ||
import configureStore from 'redux-mock-store'; | ||
import configureMockStore from 'redux-mock-store'; | ||
|
||
import thunk from 'redux-thunk'; | ||
|
||
import { mountWithContext } from '../../../test/utils/mountHelpers'; | ||
import liskServiceApi from '../../utils/api/liskService'; | ||
import Converter from './index'; | ||
|
||
describe('Converter', () => { | ||
let explorereApiMock; | ||
let wrapper; | ||
const fakeStore = configureStore(); | ||
const store = fakeStore({ | ||
settings: {}, | ||
settingsUpdated: () => {}, | ||
}); | ||
|
||
beforeEach(() => { | ||
explorereApiMock = sinon.stub(liskServiceApi, 'getPriceTicker').returnsPromise(); | ||
}); | ||
|
||
afterEach(() => { | ||
explorereApiMock.restore(); | ||
const store = configureMockStore([thunk])({ | ||
settings: { currency: 'USD' }, | ||
settingsUpdated: () => {}, | ||
getPriceTicker: () => {}, | ||
liskService: {}, | ||
}); | ||
|
||
it('shold render Converter component', () => { | ||
const props = { | ||
t: key => key, | ||
settings: { currency: 'EUR' }, | ||
priceTicker: { LSK: { USD: 123, EUR: 12 } }, | ||
}; | ||
|
||
wrapper = mountWithContext(<Converter {...props} store={store}/>, { storeState: store }); | ||
expect(wrapper.find('Converter')).to.have.present(); | ||
}); | ||
|
||
it('should convert price to EUR from localStorage', () => { | ||
const storeWithCurrency = fakeStore({ | ||
settings: { currency: 'USD' }, | ||
settingsUpdated: () => {}, | ||
}); | ||
|
||
const props = { | ||
t: key => key, | ||
value: 2, | ||
error: false, | ||
currency: 'USD', | ||
}; | ||
|
||
wrapper = mountWithContext( | ||
<Converter {...props} store={storeWithCurrency}/>, | ||
{ storeState: storeWithCurrency }, | ||
); | ||
|
||
explorereApiMock.resolves({ LSK: { USD: 123, EUR: 12 } }); | ||
wrapper.update(); | ||
expect(wrapper.find('.converted-price').at(0)).to.have.text('246.00 USD'); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.