You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
4 years ago
|
import assert from 'assert';
|
||
|
import sinon from 'sinon';
|
||
|
import { ObservableStore } from '@metamask/obs-store';
|
||
4 years ago
|
import TokenRatesController from './token-rates';
|
||
7 years ago
|
|
||
5 years ago
|
describe('TokenRatesController', function () {
|
||
4 years ago
|
let nativeCurrency;
|
||
|
let getNativeCurrency;
|
||
|
beforeEach(function () {
|
||
|
nativeCurrency = 'ETH';
|
||
|
getNativeCurrency = () => nativeCurrency;
|
||
|
});
|
||
5 years ago
|
it('should listen for preferences store updates', function () {
|
||
4 years ago
|
const preferences = new ObservableStore({ tokens: [] });
|
||
|
preferences.putState({ tokens: ['foo'] });
|
||
4 years ago
|
const controller = new TokenRatesController({
|
||
|
preferences,
|
||
|
getNativeCurrency,
|
||
|
});
|
||
4 years ago
|
assert.deepEqual(controller._tokens, ['foo']);
|
||
|
});
|
||
7 years ago
|
|
||
5 years ago
|
it('should poll on correct interval', async function () {
|
||
4 years ago
|
const stub = sinon.stub(global, 'setInterval');
|
||
|
const preferences = new ObservableStore({ tokens: [] });
|
||
|
preferences.putState({ tokens: ['foo'] });
|
||
4 years ago
|
const controller = new TokenRatesController({
|
||
|
preferences,
|
||
|
getNativeCurrency,
|
||
|
});
|
||
4 years ago
|
controller.start(1337);
|
||
5 years ago
|
|
||
4 years ago
|
assert.strictEqual(stub.getCall(0).args[1], 1337);
|
||
|
stub.restore();
|
||
|
controller.stop();
|
||
|
});
|
||
|
});
|