1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-23 03:36:18 +02:00
metamask-extension/test/unit/app/controllers/token-rates-controller.test.js
Thomas Huang 3ba91df387
Unifies unit tests filename suffix to .test.js (#10607)
* Unifies the filename suffix to .test.js

* Display @babel/no-invalid-this rule for tx-controller.test.js

* Add test file extension to test:unit:global
2021-03-09 11:08:06 -08:00

38 lines
1.2 KiB
JavaScript

import assert from 'assert';
import sinon from 'sinon';
import { ObservableStore } from '@metamask/obs-store';
import TokenRatesController from '../../../../app/scripts/controllers/token-rates';
describe('TokenRatesController', function () {
let nativeCurrency;
let getNativeCurrency;
beforeEach(function () {
nativeCurrency = 'ETH';
getNativeCurrency = () => nativeCurrency;
});
it('should listen for preferences store updates', function () {
const preferences = new ObservableStore({ tokens: [] });
preferences.putState({ tokens: ['foo'] });
const controller = new TokenRatesController({
preferences,
getNativeCurrency,
});
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,
getNativeCurrency,
});
controller.start(1337);
assert.strictEqual(stub.getCall(0).args[1], 1337);
stub.restore();
controller.stop();
});
});