1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-26 05:13:37 +02:00
metamask-extension/test/unit/app/controllers/token-rates-controller.js
Mark Stacey 1f8a7a72c9
Fix TokenRatesController (#8780)
The `TokenRatesController` was accidentally broken in #8744, when the
logic for starting and stopping polling was moved from the `isActive`
property to start/stop functions.

A reference to the now-obsolete `isActive` property was accidentally
left behind, resulting in no exchange rate updates.
2020-06-10 16:53:37 -03:00

26 lines
931 B
JavaScript

import assert from 'assert'
import sinon from 'sinon'
import TokenRatesController from '../../../../app/scripts/controllers/token-rates'
import ObservableStore from 'obs-store'
describe('TokenRatesController', function () {
it('should listen for preferences store updates', function () {
const preferences = new ObservableStore({ tokens: [] })
preferences.putState({ tokens: ['foo'] })
const controller = new TokenRatesController({ preferences })
assert.deepEqual(controller._tokens, ['foo'])
})
it('should poll on correct interval', async function () {
const stub = sinon.stub(global, 'setInterval')
const preferences = new ObservableStore({ tokens: [] })
preferences.putState({ tokens: ['foo'] })
const controller = new TokenRatesController({ preferences })
controller.start(1337)
assert.strictEqual(stub.getCall(0).args[1], 1337)
stub.restore()
controller.stop()
})
})