mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
f47cfbbb3e
The `assert` module has two modes: "Legacy" and "strict". When using strict mode, the "strict" version of each assertion method is implied. Whereas in legacy mode, by default it will use the deprecated, "loose" version of each assertion. We now use strict mode everywhere. A few tests required updates where they were asserting the wrong thing, and it was passing beforehand due to the loose matching.
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
import { strict as assert } from 'assert';
|
|
import sinon from 'sinon';
|
|
import { ObservableStore } from '@metamask/obs-store';
|
|
import TokenRatesController from './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();
|
|
});
|
|
});
|