Merge remote-tracking branch 'origin/t3chguy/jest' into travis/sourcemaps

This commit is contained in:
Travis Ralston 2020-01-09 16:00:13 -07:00
commit a8c8406ac4
41 changed files with 2002 additions and 1842 deletions

View file

@ -23,17 +23,16 @@ import ReactDOM from "react-dom";
import PropTypes from "prop-types";
const TestUtils = require('react-dom/test-utils');
const expect = require('expect');
import sinon from 'sinon';
import { EventEmitter } from "events";
const sdk = require('matrix-react-sdk');
import sdk from '../../skinned-sdk';
const MessagePanel = sdk.getComponent('structures.MessagePanel');
import {MatrixClientPeg} from '../../../src/MatrixClientPeg';
import Matrix from 'matrix-js-sdk';
const test_utils = require('test-utils');
const mockclock = require('mock-clock');
const test_utils = require('../../test-utils');
const mockclock = require('../../mock-clock');
import Velocity from 'velocity-animate';
import MatrixClientContext from "../../../src/contexts/MatrixClientContext";
@ -63,17 +62,16 @@ describe('MessagePanel', function() {
const clock = mockclock.clock();
const realSetTimeout = window.setTimeout;
const events = mkEvents();
let sandbox = null;
beforeEach(function() {
test_utils.beforeEach(this);
sandbox = test_utils.stubClient();
test_utils.stubClient();
client = MatrixClientPeg.get();
client.credentials = {userId: '@me:here'};
// HACK: We assume all settings want to be disabled
SettingsStore.getValue = sinon.stub().returns(false);
SettingsStore.getValue.withArgs('showDisplaynameChanges').returns(true);
SettingsStore.getValue = jest.fn((arg) => {
return arg === "showDisplaynameChanges";
});
// This option clobbers the duration of all animations to be 1ms
// which makes unit testing a lot simpler (the animation doesn't
@ -86,7 +84,6 @@ describe('MessagePanel', function() {
delete Velocity.mock;
clock.uninstall();
sandbox.restore();
});
function mkEvents() {