Fix the MessagePanel test

Signed-off-by: Travis Ralston <travpc@gmail.com>
pull/21833/head
turt2live 2017-09-14 20:47:24 -06:00
parent 3c71898237
commit 0363f73e28
3 changed files with 8 additions and 4 deletions

View File

@ -97,12 +97,12 @@ const COMMANDS = [
{ {
command: '/ignore', command: '/ignore',
args: '<user-id>', args: '<user-id>',
description: 'Ignores a user, hiding their messages from you' description: 'Ignores a user, hiding their messages from you',
}, },
{ {
command: '/unignore', command: '/unignore',
args: '<user-id>', args: '<user-id>',
description: 'Stops ignoring a user, showing their messages going forward' description: 'Stops ignoring a user, showing their messages going forward',
}, },
// Omitting `/markdown` as it only seems to apply to OldComposer // Omitting `/markdown` as it only seems to apply to OldComposer
]; ];

View File

@ -241,7 +241,7 @@ module.exports = React.createClass({
// TODO: Implement granular (per-room) hide options // TODO: Implement granular (per-room) hide options
_shouldShowEvent: function(mxEv) { _shouldShowEvent: function(mxEv) {
if (MatrixClientPeg.get().isUserIgnored(mxEv.sender.userId)) { if (mxEv.sender && MatrixClientPeg.get().isUserIgnored(mxEv.sender.userId)) {
return false; // ignored = no show (only happens if the ignore happens after an event was received) return false; // ignored = no show (only happens if the ignore happens after an event was received)
} }

View File

@ -24,6 +24,7 @@ var sdk = require('matrix-react-sdk');
var MessagePanel = sdk.getComponent('structures.MessagePanel'); var MessagePanel = sdk.getComponent('structures.MessagePanel');
import UserSettingsStore from '../../../src/UserSettingsStore'; import UserSettingsStore from '../../../src/UserSettingsStore';
import MatrixClientPeg from '../../../src/MatrixClientPeg';
var test_utils = require('test-utils'); var test_utils = require('test-utils');
var mockclock = require('mock-clock'); var mockclock = require('mock-clock');
@ -51,16 +52,19 @@ describe('MessagePanel', function () {
var clock = mockclock.clock(); var clock = mockclock.clock();
var realSetTimeout = window.setTimeout; var realSetTimeout = window.setTimeout;
var events = mkEvents(); var events = mkEvents();
var sandbox = null;
beforeEach(function() { beforeEach(function() {
test_utils.beforeEach(this); test_utils.beforeEach(this);
client = test_utils.createTestClient(); sandbox = test_utils.stubClient();
client = MatrixClientPeg.get();
client.credentials = {userId: '@me:here'}; client.credentials = {userId: '@me:here'};
UserSettingsStore.getSyncedSettings = sinon.stub().returns({}); UserSettingsStore.getSyncedSettings = sinon.stub().returns({});
}); });
afterEach(function() { afterEach(function() {
clock.uninstall(); clock.uninstall();
sandbox.restore();
}); });
function mkEvents() { function mkEvents() {