30 test failures to go :D
This commit is contained in:
parent
ffa2ac172c
commit
6ad31fe023
33 changed files with 424 additions and 709 deletions
|
@ -17,14 +17,13 @@ limitations under the License.
|
|||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import ReactTestUtils from 'react-dom/test-utils';
|
||||
import expect from 'expect';
|
||||
|
||||
import MockHttpBackend from 'matrix-mock-request';
|
||||
import MatrixClientPeg from '../../../src/MatrixClientPeg';
|
||||
import sdk from 'matrix-react-sdk';
|
||||
import sdk from '../../skinned-sdk';
|
||||
import Matrix from 'matrix-js-sdk';
|
||||
|
||||
import * as TestUtils from 'test-utils';
|
||||
import * as TestUtils from '../../test-utils';
|
||||
const { waitForUpdate } = TestUtils;
|
||||
|
||||
const GroupView = sdk.getComponent('structures.GroupView');
|
||||
|
|
|
@ -23,10 +23,9 @@ 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';
|
||||
|
@ -72,15 +71,14 @@ describe('MessagePanel', function() {
|
|||
const clock = mockclock.clock();
|
||||
const realSetTimeout = window.setTimeout;
|
||||
const events = mkEvents();
|
||||
let sandbox = null;
|
||||
|
||||
beforeEach(function() {
|
||||
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 = jest.fn().returns(false);
|
||||
SettingsStore.getValue.withArgs('showDisplaynameChanges').returns(true);
|
||||
|
||||
// This option clobbers the duration of all animations to be 1ms
|
||||
|
@ -94,7 +92,6 @@ describe('MessagePanel', function() {
|
|||
delete Velocity.mock;
|
||||
|
||||
clock.uninstall();
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
function mkEvents() {
|
||||
|
|
|
@ -14,12 +14,10 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import expect from 'expect';
|
||||
import sinon from 'sinon';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import ReactTestUtils from 'react-dom/test-utils';
|
||||
import sdk from 'matrix-react-sdk';
|
||||
import sdk from '../../../skinned-sdk';
|
||||
import SdkConfig from '../../../../src/SdkConfig';
|
||||
import {mkServerConfig} from "../../../test-utils";
|
||||
|
||||
|
@ -36,7 +34,6 @@ describe('Login', function() {
|
|||
});
|
||||
|
||||
afterEach(function() {
|
||||
sinon.restore();
|
||||
ReactDOM.unmountComponentAtNode(parentDiv);
|
||||
parentDiv.remove();
|
||||
});
|
||||
|
@ -72,7 +69,7 @@ describe('Login', function() {
|
|||
});
|
||||
|
||||
it('should show form without change server link when custom URLs disabled', function() {
|
||||
sinon.stub(SdkConfig, "get").returns({
|
||||
jest.spyOn(SdkConfig, "get").returns({
|
||||
disable_custom_urls: true,
|
||||
});
|
||||
|
||||
|
|
|
@ -14,12 +14,10 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import expect from 'expect';
|
||||
import sinon from 'sinon';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import ReactTestUtils from 'react-dom/test-utils';
|
||||
import sdk from 'matrix-react-sdk';
|
||||
import sdk from '../../../skinned-sdk';
|
||||
import SdkConfig from '../../../../src/SdkConfig';
|
||||
import {mkServerConfig} from "../../../test-utils";
|
||||
|
||||
|
@ -36,7 +34,6 @@ describe('Registration', function() {
|
|||
});
|
||||
|
||||
afterEach(function() {
|
||||
sinon.restore();
|
||||
ReactDOM.unmountComponentAtNode(parentDiv);
|
||||
parentDiv.remove();
|
||||
});
|
||||
|
@ -61,7 +58,7 @@ describe('Registration', function() {
|
|||
});
|
||||
|
||||
it('should show form when custom URLs disabled', function() {
|
||||
sinon.stub(SdkConfig, "get").returns({
|
||||
jest.spyOn(SdkConfig, "get").returns({
|
||||
disable_custom_urls: true,
|
||||
});
|
||||
|
||||
|
|
|
@ -14,14 +14,12 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import expect from 'expect';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import ReactTestUtils from 'react-dom/test-utils';
|
||||
import sinon from 'sinon';
|
||||
import MatrixReactTestUtils from 'matrix-react-test-utils';
|
||||
|
||||
import sdk from 'matrix-react-sdk';
|
||||
import sdk from '../../../skinned-sdk';
|
||||
import MatrixClientPeg from '../../../../src/MatrixClientPeg';
|
||||
|
||||
import * as test_utils from '../../../test-utils';
|
||||
|
@ -33,10 +31,9 @@ const InteractiveAuthDialog = sdk.getComponent(
|
|||
|
||||
describe('InteractiveAuthDialog', function() {
|
||||
let parentDiv;
|
||||
let sandbox;
|
||||
|
||||
beforeEach(function() {
|
||||
sandbox = test_utils.stubClient(sandbox);
|
||||
test_utils.stubClient();
|
||||
parentDiv = document.createElement('div');
|
||||
document.body.appendChild(parentDiv);
|
||||
});
|
||||
|
@ -44,12 +41,11 @@ describe('InteractiveAuthDialog', function() {
|
|||
afterEach(function() {
|
||||
ReactDOM.unmountComponentAtNode(parentDiv);
|
||||
parentDiv.remove();
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
it('Should successfully complete a password flow', function() {
|
||||
const onFinished = sinon.spy();
|
||||
const doRequest = sinon.stub().returns(Promise.resolve({a: 1}));
|
||||
const onFinished = jest.fn();
|
||||
const doRequest = jest.fn().mockResolvedValue({a: 1});
|
||||
|
||||
// tell the stub matrixclient to return a real userid
|
||||
const client = MatrixClientPeg.get();
|
||||
|
@ -108,8 +104,8 @@ describe('InteractiveAuthDialog', function() {
|
|||
// let the request complete
|
||||
return sleep(1);
|
||||
}).then(() => {
|
||||
expect(onFinished.callCount).toEqual(1);
|
||||
expect(onFinished.calledWithExactly(true, {a: 1})).toBe(true);
|
||||
expect(onFinished).toBeCalledTimes(1);
|
||||
expect(onFinished).toBeCalledWith(true, {a: 1});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import expect from 'expect';
|
||||
import React from 'react';
|
||||
import ReactTestUtils from 'react-dom/test-utils';
|
||||
import ShallowRenderer from "react-test-renderer/shallow";
|
||||
import sdk from 'matrix-react-sdk';
|
||||
import sdk from '../../../skinned-sdk';
|
||||
import * as languageHandler from '../../../../src/languageHandler';
|
||||
import * as testUtils from '../../../test-utils';
|
||||
|
||||
|
@ -12,8 +11,6 @@ const MemberEventListSummary = testUtils.wrapInMatrixClientContext(
|
|||
);
|
||||
|
||||
describe('MemberEventListSummary', function() {
|
||||
let sandbox;
|
||||
|
||||
// Generate dummy event tiles for use in simulating an expanded MELS
|
||||
const generateTiles = (events) => {
|
||||
return events.map((e) => {
|
||||
|
@ -88,7 +85,7 @@ describe('MemberEventListSummary', function() {
|
|||
};
|
||||
|
||||
beforeEach(function(done) {
|
||||
sandbox = testUtils.stubClient();
|
||||
testUtils.stubClient();
|
||||
|
||||
languageHandler.setLanguage('en').then(done);
|
||||
languageHandler.setMissingEntryGenerator(function(key) {
|
||||
|
@ -96,10 +93,6 @@ describe('MemberEventListSummary', function() {
|
|||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
it('renders expanded events if there are less than props.threshold', function() {
|
||||
const events = generateEvents([
|
||||
{userId: "@user_1:some.domain", prevMembership: "leave", membership: "join"},
|
||||
|
|
|
@ -17,14 +17,13 @@ limitations under the License.
|
|||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import ReactTestUtils from "react-dom/test-utils";
|
||||
import expect from "expect";
|
||||
|
||||
import MockHttpBackend from "matrix-mock-request";
|
||||
import MatrixClientPeg from "../../../../src/MatrixClientPeg";
|
||||
import sdk from "matrix-react-sdk";
|
||||
import sdk from "../../../skinned-sdk";
|
||||
import Matrix from "matrix-js-sdk";
|
||||
|
||||
import * as TestUtils from "test-utils";
|
||||
import * as TestUtils from "../../../test-utils";
|
||||
const { waitForUpdate } = TestUtils;
|
||||
|
||||
const GroupMemberList = sdk.getComponent("views.groups.GroupMemberList");
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import React from 'react';
|
||||
import ReactTestUtils from 'react-dom/test-utils';
|
||||
import ReactDOM from 'react-dom';
|
||||
import expect from 'expect';
|
||||
import lolex from 'lolex';
|
||||
|
||||
import * as TestUtils from 'test-utils';
|
||||
import * as TestUtils from '../../../test-utils';
|
||||
|
||||
import sdk from '../../../../src/index';
|
||||
import MatrixClientPeg from '../../../../src/MatrixClientPeg';
|
||||
|
@ -26,7 +25,6 @@ describe('MemberList', () => {
|
|||
}
|
||||
|
||||
let parentDiv = null;
|
||||
let sandbox = null;
|
||||
let client = null;
|
||||
let root = null;
|
||||
let clock = null;
|
||||
|
@ -38,7 +36,7 @@ describe('MemberList', () => {
|
|||
let defaultUsers = [];
|
||||
|
||||
beforeEach(function() {
|
||||
sandbox = TestUtils.stubClient(sandbox);
|
||||
TestUtils.stubClient();
|
||||
client = MatrixClientPeg.get();
|
||||
client.hasLazyLoadMembersEnabled = () => false;
|
||||
|
||||
|
@ -115,7 +113,6 @@ describe('MemberList', () => {
|
|||
parentDiv.remove();
|
||||
parentDiv = null;
|
||||
}
|
||||
sandbox.restore();
|
||||
|
||||
clock.uninstall();
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import React from 'react';
|
||||
import ReactTestUtils from 'react-dom/test-utils';
|
||||
import ReactDOM from 'react-dom';
|
||||
import expect from 'expect';
|
||||
import sinon from 'sinon';
|
||||
import * as testUtils from '../../../test-utils';
|
||||
import sdk from 'matrix-react-sdk';
|
||||
import sdk from '../../../skinned-sdk';
|
||||
const MessageComposerInput = sdk.getComponent('views.rooms.MessageComposerInput');
|
||||
import MatrixClientPeg from '../../../../src/MatrixClientPeg';
|
||||
import {sleep} from "../../../../src/utils/promise";
|
||||
|
@ -23,13 +21,12 @@ function addTextToDraft(text) {
|
|||
|
||||
xdescribe('MessageComposerInput', () => {
|
||||
let parentDiv = null,
|
||||
sandbox = null,
|
||||
client = null,
|
||||
mci = null,
|
||||
room = testUtils.mkStubRoom('!DdJkzRliezrwpNebLk:matrix.org');
|
||||
|
||||
beforeEach(function() {
|
||||
sandbox = testUtils.stubClient(sandbox);
|
||||
testUtils.stubClient();
|
||||
client = MatrixClientPeg.get();
|
||||
client.credentials = {userId: '@me:domain.com'};
|
||||
|
||||
|
@ -54,7 +51,6 @@ xdescribe('MessageComposerInput', () => {
|
|||
parentDiv.remove();
|
||||
parentDiv = null;
|
||||
}
|
||||
sandbox.restore();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -75,66 +71,66 @@ xdescribe('MessageComposerInput', () => {
|
|||
});
|
||||
|
||||
it('should not send messages when composer is empty', () => {
|
||||
const spy = sinon.spy(client, 'sendMessage');
|
||||
const spy = jest.spyOn(client, 'sendMessage');
|
||||
mci.enableRichtext(true);
|
||||
mci.handleReturn(sinon.stub());
|
||||
mci.handleReturn(jest.fn());
|
||||
|
||||
expect(spy.calledOnce).toEqual(false, 'should not send message');
|
||||
expect(spy).not.toBeCalled();
|
||||
});
|
||||
|
||||
it('should not change content unnecessarily on RTE -> Markdown conversion', () => {
|
||||
const spy = sinon.spy(client, 'sendMessage');
|
||||
const spy = jest.spyOn(client, 'sendMessage');
|
||||
mci.enableRichtext(true);
|
||||
addTextToDraft('a');
|
||||
mci.handleKeyCommand('toggle-mode');
|
||||
mci.handleReturn(sinon.stub());
|
||||
mci.handleReturn(jest.fn());
|
||||
|
||||
expect(spy.calledOnce).toEqual(true);
|
||||
expect(spy.args[0][1].body).toEqual('a');
|
||||
});
|
||||
|
||||
it('should not change content unnecessarily on Markdown -> RTE conversion', () => {
|
||||
const spy = sinon.spy(client, 'sendMessage');
|
||||
const spy = jest.spyOn(client, 'sendMessage');
|
||||
mci.enableRichtext(false);
|
||||
addTextToDraft('a');
|
||||
mci.handleKeyCommand('toggle-mode');
|
||||
mci.handleReturn(sinon.stub());
|
||||
mci.handleReturn(jest.fn());
|
||||
|
||||
expect(spy.calledOnce).toEqual(true);
|
||||
expect(spy.args[0][1].body).toEqual('a');
|
||||
});
|
||||
|
||||
it('should send emoji messages when rich text is enabled', () => {
|
||||
const spy = sinon.spy(client, 'sendMessage');
|
||||
const spy = jest.spyOn(client, 'sendMessage');
|
||||
mci.enableRichtext(true);
|
||||
addTextToDraft('☹');
|
||||
mci.handleReturn(sinon.stub());
|
||||
mci.handleReturn(jest.fn());
|
||||
|
||||
expect(spy.calledOnce).toEqual(true, 'should send message');
|
||||
});
|
||||
|
||||
it('should send emoji messages when Markdown is enabled', () => {
|
||||
const spy = sinon.spy(client, 'sendMessage');
|
||||
const spy = jest.spyOn(client, 'sendMessage');
|
||||
mci.enableRichtext(false);
|
||||
addTextToDraft('☹');
|
||||
mci.handleReturn(sinon.stub());
|
||||
mci.handleReturn(jest.fn());
|
||||
|
||||
expect(spy.calledOnce).toEqual(true, 'should send message');
|
||||
});
|
||||
|
||||
// FIXME
|
||||
// it('should convert basic Markdown to rich text correctly', () => {
|
||||
// const spy = sinon.spy(client, 'sendHtmlMessage');
|
||||
// const spy = jest.spyOn(client, 'sendHtmlMessage');
|
||||
// mci.enableRichtext(false);
|
||||
// addTextToDraft('*abc*');
|
||||
// mci.handleKeyCommand('toggle-mode');
|
||||
// mci.handleReturn(sinon.stub());
|
||||
// mci.handleReturn(jest.fn());
|
||||
// console.error(spy.args[0][2]);
|
||||
// expect(spy.args[0][2]).toContain('<em>abc');
|
||||
// });
|
||||
//
|
||||
// it('should convert basic rich text to Markdown correctly', () => {
|
||||
// const spy = sinon.spy(client, 'sendHtmlMessage');
|
||||
// const spy = jest.spyOn(client, 'sendHtmlMessage');
|
||||
// mci.enableRichtext(true);
|
||||
// process.nextTick(() => {
|
||||
//
|
||||
|
@ -142,43 +138,43 @@ xdescribe('MessageComposerInput', () => {
|
|||
// mci.handleKeyCommand('italic');
|
||||
// addTextToDraft('abc');
|
||||
// mci.handleKeyCommand('toggle-mode');
|
||||
// mci.handleReturn(sinon.stub());
|
||||
// mci.handleReturn(jest.fn());
|
||||
// expect(['_abc_', '*abc*']).toContain(spy.args[0][1]);
|
||||
// });
|
||||
|
||||
it('should insert formatting characters in Markdown mode', () => {
|
||||
const spy = sinon.spy(client, 'sendMessage');
|
||||
const spy = jest.spyOn(client, 'sendMessage');
|
||||
mci.enableRichtext(false);
|
||||
mci.handleKeyCommand('italic');
|
||||
mci.handleReturn(sinon.stub());
|
||||
mci.handleReturn(jest.fn());
|
||||
expect(['__', '**']).toContain(spy.args[0][1].body);
|
||||
});
|
||||
|
||||
it('should not entity-encode " in Markdown mode', () => {
|
||||
const spy = sinon.spy(client, 'sendMessage');
|
||||
const spy = jest.spyOn(client, 'sendMessage');
|
||||
mci.enableRichtext(false);
|
||||
addTextToDraft('"');
|
||||
mci.handleReturn(sinon.stub());
|
||||
mci.handleReturn(jest.fn());
|
||||
|
||||
expect(spy.calledOnce).toEqual(true);
|
||||
expect(spy.args[0][1].body).toEqual('"');
|
||||
});
|
||||
|
||||
it('should escape characters without other markup in Markdown mode', () => {
|
||||
const spy = sinon.spy(client, 'sendMessage');
|
||||
const spy = jest.spyOn(client, 'sendMessage');
|
||||
mci.enableRichtext(false);
|
||||
addTextToDraft('\\*escaped\\*');
|
||||
mci.handleReturn(sinon.stub());
|
||||
mci.handleReturn(jest.fn());
|
||||
|
||||
expect(spy.calledOnce).toEqual(true);
|
||||
expect(spy.args[0][1].body).toEqual('*escaped*');
|
||||
});
|
||||
|
||||
it('should escape characters with other markup in Markdown mode', () => {
|
||||
const spy = sinon.spy(client, 'sendMessage');
|
||||
const spy = jest.spyOn(client, 'sendMessage');
|
||||
mci.enableRichtext(false);
|
||||
addTextToDraft('\\*escaped\\* *italic*');
|
||||
mci.handleReturn(sinon.stub());
|
||||
mci.handleReturn(jest.fn());
|
||||
|
||||
expect(spy.calledOnce).toEqual(true);
|
||||
expect(spy.args[0][1].body).toEqual('\\*escaped\\* *italic*');
|
||||
|
@ -186,20 +182,20 @@ xdescribe('MessageComposerInput', () => {
|
|||
});
|
||||
|
||||
it('should not convert -_- into a horizontal rule in Markdown mode', () => {
|
||||
const spy = sinon.spy(client, 'sendMessage');
|
||||
const spy = jest.spyOn(client, 'sendMessage');
|
||||
mci.enableRichtext(false);
|
||||
addTextToDraft('-_-');
|
||||
mci.handleReturn(sinon.stub());
|
||||
mci.handleReturn(jest.fn());
|
||||
|
||||
expect(spy.calledOnce).toEqual(true);
|
||||
expect(spy.args[0][1].body).toEqual('-_-');
|
||||
});
|
||||
|
||||
it('should not strip <del> tags in Markdown mode', () => {
|
||||
const spy = sinon.spy(client, 'sendMessage');
|
||||
const spy = jest.spyOn(client, 'sendMessage');
|
||||
mci.enableRichtext(false);
|
||||
addTextToDraft('<del>striked-out</del>');
|
||||
mci.handleReturn(sinon.stub());
|
||||
mci.handleReturn(jest.fn());
|
||||
|
||||
expect(spy.calledOnce).toEqual(true);
|
||||
expect(spy.args[0][1].body).toEqual('<del>striked-out</del>');
|
||||
|
@ -207,30 +203,30 @@ xdescribe('MessageComposerInput', () => {
|
|||
});
|
||||
|
||||
it('should not strike-through ~~~ in Markdown mode', () => {
|
||||
const spy = sinon.spy(client, 'sendMessage');
|
||||
const spy = jest.spyOn(client, 'sendMessage');
|
||||
mci.enableRichtext(false);
|
||||
addTextToDraft('~~~striked-out~~~');
|
||||
mci.handleReturn(sinon.stub());
|
||||
mci.handleReturn(jest.fn());
|
||||
|
||||
expect(spy.calledOnce).toEqual(true);
|
||||
expect(spy.args[0][1].body).toEqual('~~~striked-out~~~');
|
||||
});
|
||||
|
||||
it('should not mark single unmarkedup paragraphs as HTML in Markdown mode', () => {
|
||||
const spy = sinon.spy(client, 'sendMessage');
|
||||
const spy = jest.spyOn(client, 'sendMessage');
|
||||
mci.enableRichtext(false);
|
||||
addTextToDraft('Lorem ipsum dolor sit amet, consectetur adipiscing elit.');
|
||||
mci.handleReturn(sinon.stub());
|
||||
mci.handleReturn(jest.fn());
|
||||
|
||||
expect(spy.calledOnce).toEqual(true);
|
||||
expect(spy.args[0][1].body).toEqual('Lorem ipsum dolor sit amet, consectetur adipiscing elit.');
|
||||
});
|
||||
|
||||
it('should not mark two unmarkedup paragraphs as HTML in Markdown mode', () => {
|
||||
const spy = sinon.spy(client, 'sendMessage');
|
||||
const spy = jest.spyOn(client, 'sendMessage');
|
||||
mci.enableRichtext(false);
|
||||
addTextToDraft('Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n\nFusce congue sapien sed neque molestie volutpat.');
|
||||
mci.handleReturn(sinon.stub());
|
||||
mci.handleReturn(jest.fn());
|
||||
|
||||
expect(spy.calledOnce).toEqual(true);
|
||||
expect(spy.args[0][1].body).toEqual('Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n\nFusce congue sapien sed neque molestie volutpat.');
|
||||
|
@ -238,7 +234,7 @@ xdescribe('MessageComposerInput', () => {
|
|||
|
||||
it('should strip tab-completed mentions so that only the display name is sent in the plain body in Markdown mode', () => {
|
||||
// Sending a HTML message because we have entities in the composer (because of completions)
|
||||
const spy = sinon.spy(client, 'sendMessage');
|
||||
const spy = jest.spyOn(client, 'sendMessage');
|
||||
mci.enableRichtext(false);
|
||||
mci.setDisplayedCompletion({
|
||||
completion: 'Some Member',
|
||||
|
@ -246,7 +242,7 @@ xdescribe('MessageComposerInput', () => {
|
|||
href: `https://matrix.to/#/@some_member:domain.bla`,
|
||||
});
|
||||
|
||||
mci.handleReturn(sinon.stub());
|
||||
mci.handleReturn(jest.fn());
|
||||
|
||||
expect(spy.args[0][1].body).toEqual(
|
||||
'Some Member',
|
||||
|
@ -260,7 +256,7 @@ xdescribe('MessageComposerInput', () => {
|
|||
|
||||
it('should strip tab-completed mentions so that only the display name is sent in the plain body in RTE mode', () => {
|
||||
// Sending a HTML message because we have entities in the composer (because of completions)
|
||||
const spy = sinon.spy(client, 'sendMessage');
|
||||
const spy = jest.spyOn(client, 'sendMessage');
|
||||
mci.enableRichtext(true);
|
||||
mci.setDisplayedCompletion({
|
||||
completion: 'Some Member',
|
||||
|
@ -268,7 +264,7 @@ xdescribe('MessageComposerInput', () => {
|
|||
href: `https://matrix.to/#/@some_member:domain.bla`,
|
||||
});
|
||||
|
||||
mci.handleReturn(sinon.stub());
|
||||
mci.handleReturn(jest.fn());
|
||||
|
||||
expect(spy.args[0][1].body).toEqual('Some Member');
|
||||
expect(spy.args[0][1].formatted_body).toEqual('<a href="https://matrix.to/#/@some_member:domain.bla">Some Member</a>');
|
||||
|
@ -276,12 +272,12 @@ xdescribe('MessageComposerInput', () => {
|
|||
|
||||
it('should not strip non-tab-completed mentions when manually typing MD', () => {
|
||||
// Sending a HTML message because we have entities in the composer (because of completions)
|
||||
const spy = sinon.spy(client, 'sendMessage');
|
||||
const spy = jest.spyOn(client, 'sendMessage');
|
||||
// Markdown mode enabled
|
||||
mci.enableRichtext(false);
|
||||
addTextToDraft('[My Not-Tab-Completed Mention](https://matrix.to/#/@some_member:domain.bla)');
|
||||
|
||||
mci.handleReturn(sinon.stub());
|
||||
mci.handleReturn(jest.fn());
|
||||
|
||||
expect(spy.args[0][1].body).toEqual('[My Not-Tab-Completed Mention](https://matrix.to/#/@some_member:domain.bla)');
|
||||
expect(spy.args[0][1].formatted_body).toEqual('<a href="https://matrix.to/#/@some_member:domain.bla">My Not-Tab-Completed Mention</a>');
|
||||
|
@ -289,12 +285,12 @@ xdescribe('MessageComposerInput', () => {
|
|||
|
||||
it('should not strip arbitrary typed (i.e. not tab-completed) MD links', () => {
|
||||
// Sending a HTML message because we have entities in the composer (because of completions)
|
||||
const spy = sinon.spy(client, 'sendMessage');
|
||||
const spy = jest.spyOn(client, 'sendMessage');
|
||||
// Markdown mode enabled
|
||||
mci.enableRichtext(false);
|
||||
addTextToDraft('[Click here](https://some.lovely.url)');
|
||||
|
||||
mci.handleReturn(sinon.stub());
|
||||
mci.handleReturn(jest.fn());
|
||||
|
||||
expect(spy.args[0][1].body).toEqual('[Click here](https://some.lovely.url)');
|
||||
expect(spy.args[0][1].formatted_body).toEqual('<a href="https://some.lovely.url">Click here</a>');
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import React from 'react';
|
||||
import ReactTestUtils from 'react-dom/test-utils';
|
||||
import ReactDOM from 'react-dom';
|
||||
import expect from 'expect';
|
||||
import lolex from 'lolex';
|
||||
|
||||
import * as TestUtils from 'test-utils';
|
||||
import * as TestUtils from '../../../test-utils';
|
||||
|
||||
import sdk from '../../../../src/index';
|
||||
import MatrixClientPeg from '../../../../src/MatrixClientPeg';
|
||||
|
@ -31,7 +30,6 @@ describe('RoomList', () => {
|
|||
}
|
||||
|
||||
let parentDiv = null;
|
||||
let sandbox = null;
|
||||
let client = null;
|
||||
let root = null;
|
||||
const myUserId = '@me:domain';
|
||||
|
@ -45,7 +43,7 @@ describe('RoomList', () => {
|
|||
let myOtherMember;
|
||||
|
||||
beforeEach(function() {
|
||||
sandbox = TestUtils.stubClient(sandbox);
|
||||
TestUtils.stubClient();
|
||||
client = MatrixClientPeg.get();
|
||||
client.credentials = {userId: myUserId};
|
||||
//revert this to prototype method as the test-utils monkey-patches this to return a hardcoded value
|
||||
|
@ -111,7 +109,6 @@ describe('RoomList', () => {
|
|||
parentDiv.remove();
|
||||
parentDiv = null;
|
||||
}
|
||||
sandbox.restore();
|
||||
|
||||
clock.uninstall();
|
||||
|
||||
|
|
|
@ -1,190 +1,187 @@
|
|||
// TODO: Rewrite room settings tests for dialog support
|
||||
// import React from 'react';
|
||||
// import ReactDOM from 'react-dom';
|
||||
// import expect from 'expect';
|
||||
// import jest from 'jest-mock';
|
||||
// import * as testUtils from '../../../test-utils';
|
||||
// import sdk from 'matrix-react-sdk';
|
||||
// const WrappedRoomSettings = testUtils.wrapInMatrixClientContext(sdk.getComponent('views.rooms.RoomSettings'));
|
||||
// import MatrixClientPeg from '../../../../src/MatrixClientPeg';
|
||||
// import SettingsStore from '../../../../src/settings/SettingsStore';
|
||||
//
|
||||
//
|
||||
// describe('RoomSettings', () => {
|
||||
// let parentDiv = null;
|
||||
// let sandbox = null;
|
||||
// let client = null;
|
||||
// let roomSettings = null;
|
||||
// const room = testUtils.mkStubRoom('!DdJkzRliezrwpNebLk:matrix.org');
|
||||
//
|
||||
// function expectSentStateEvent(roomId, eventType, expectedEventContent) {
|
||||
// let found = false;
|
||||
// for (const call of client.sendStateEvent.mock.calls) {
|
||||
// const [
|
||||
// actualRoomId,
|
||||
// actualEventType,
|
||||
// actualEventContent,
|
||||
// ] = call.slice(0, 3);
|
||||
//
|
||||
// if (roomId === actualRoomId && actualEventType === eventType) {
|
||||
// expect(actualEventContent).toEqual(expectedEventContent);
|
||||
// found = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// expect(found).toBe(true);
|
||||
// }
|
||||
//
|
||||
// beforeEach(function(done) {
|
||||
// sandbox = testUtils.stubClient();
|
||||
// client = MatrixClientPeg.get();
|
||||
// client.credentials = {userId: '@me:domain.com'};
|
||||
//
|
||||
// client.setRoomName = jest.fn().mockReturnValue(Promise.resolve());
|
||||
// client.setRoomTopic = jest.fn().mockReturnValue(Promise.resolve());
|
||||
// client.setRoomDirectoryVisibility = jest.fn().mockReturnValue(Promise.resolve());
|
||||
//
|
||||
// // Covers any room state event (e.g. name, avatar, topic)
|
||||
// client.sendStateEvent = jest.fn().mockReturnValue(Promise.resolve());
|
||||
//
|
||||
// // Covers room tagging
|
||||
// client.setRoomTag = jest.fn().mockReturnValue(Promise.resolve());
|
||||
// client.deleteRoomTag = jest.fn().mockReturnValue(Promise.resolve());
|
||||
//
|
||||
// // Covers any setting in the SettingsStore
|
||||
// // (including local client settings not stored via matrix)
|
||||
// SettingsStore.setValue = jest.fn().mockReturnValue(Promise.resolve());
|
||||
//
|
||||
// parentDiv = document.createElement('div');
|
||||
// document.body.appendChild(parentDiv);
|
||||
//
|
||||
// const gatherWrappedRef = (r) => {roomSettings = r;};
|
||||
//
|
||||
// // get use wrappedRef because we're using wrapInMatrixClientContext
|
||||
// ReactDOM.render(
|
||||
// <WrappedRoomSettings
|
||||
// wrappedRef={gatherWrappedRef}
|
||||
// room={room}
|
||||
// />,
|
||||
// parentDiv,
|
||||
// done,
|
||||
// );
|
||||
// });
|
||||
//
|
||||
// afterEach((done) => {
|
||||
// if (parentDiv) {
|
||||
// ReactDOM.unmountComponentAtNode(parentDiv);
|
||||
// parentDiv.remove();
|
||||
// parentDiv = null;
|
||||
// }
|
||||
// sandbox.restore();
|
||||
// done();
|
||||
// });
|
||||
//
|
||||
// it('should not set when no setting is changed', (done) => {
|
||||
// roomSettings.save().then(() => {
|
||||
// expect(client.sendStateEvent).not.toHaveBeenCalled();
|
||||
// expect(client.setRoomTag).not.toHaveBeenCalled();
|
||||
// expect(client.deleteRoomTag).not.toHaveBeenCalled();
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// // XXX: Apparently we do call SettingsStore.setValue
|
||||
// xit('should not settings via the SettingsStore when no setting is changed', (done) => {
|
||||
// roomSettings.save().then(() => {
|
||||
// expect(SettingsStore.setValue).not.toHaveBeenCalled();
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// it('should set room name when it has changed', (done) => {
|
||||
// const name = "My Room Name";
|
||||
// roomSettings.setName(name);
|
||||
//
|
||||
// roomSettings.save().then(() => {
|
||||
// expect(client.setRoomName.mock.calls[0].slice(0, 2))
|
||||
// .toEqual(['!DdJkzRliezrwpNebLk:matrix.org', name]);
|
||||
//
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// it('should set room topic when it has changed', (done) => {
|
||||
// const topic = "this is a topic";
|
||||
// roomSettings.setTopic(topic);
|
||||
//
|
||||
// roomSettings.save().then(() => {
|
||||
// expect(client.setRoomTopic.mock.calls[0].slice(0, 2))
|
||||
// .toEqual(['!DdJkzRliezrwpNebLk:matrix.org', topic]);
|
||||
//
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// it('should set history visibility when it has changed', (done) => {
|
||||
// const historyVisibility = "translucent";
|
||||
// roomSettings.setState({
|
||||
// history_visibility: historyVisibility,
|
||||
// });
|
||||
//
|
||||
// roomSettings.save().then(() => {
|
||||
// expectSentStateEvent(
|
||||
// "!DdJkzRliezrwpNebLk:matrix.org",
|
||||
// "m.room.history_visibility", {history_visibility: historyVisibility},
|
||||
// );
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// // XXX: Can't test this because we `getRoomDirectoryVisibility` in `componentWillMount`
|
||||
// xit('should set room directory publicity when set to true', (done) => {
|
||||
// const isRoomPublished = true;
|
||||
// roomSettings.setState({
|
||||
// isRoomPublished,
|
||||
// }, () => {
|
||||
// roomSettings.save().then(() => {
|
||||
// expect(client.setRoomDirectoryVisibility.calls[0].arguments.slice(0, 2))
|
||||
// .toEqual("!DdJkzRliezrwpNebLk:matrix.org", isRoomPublished ? "public" : "private");
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// it('should set power levels when changed', (done) => {
|
||||
// roomSettings.onPowerLevelsChanged(42, "invite");
|
||||
//
|
||||
// roomSettings.save().then(() => {
|
||||
// expectSentStateEvent(
|
||||
// "!DdJkzRliezrwpNebLk:matrix.org",
|
||||
// "m.room.power_levels", { invite: 42 },
|
||||
// );
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// it('should set event power levels when changed', (done) => {
|
||||
// roomSettings.onPowerLevelsChanged(42, "event_levels_m.room.message");
|
||||
//
|
||||
// roomSettings.save().then(() => {
|
||||
// // We expect all state events to be set to the state_default (50)
|
||||
// // See powerLevelDescriptors in RoomSettings
|
||||
// expectSentStateEvent(
|
||||
// "!DdJkzRliezrwpNebLk:matrix.org",
|
||||
// "m.room.power_levels", {
|
||||
// events: {
|
||||
// 'm.room.message': 42,
|
||||
// 'm.room.avatar': 50,
|
||||
// 'm.room.name': 50,
|
||||
// 'm.room.canonical_alias': 50,
|
||||
// 'm.room.history_visibility': 50,
|
||||
// 'm.room.power_levels': 50,
|
||||
// 'm.room.topic': 50,
|
||||
// 'im.vector.modular.widgets': 50,
|
||||
// },
|
||||
// },
|
||||
// );
|
||||
// done();
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import jest from 'jest-mock';
|
||||
import * as testUtils from '../../../test-utils';
|
||||
import sdk from '../../../skinned-sdk';
|
||||
const WrappedRoomSettings = testUtils.wrapInMatrixClientContext(sdk.getComponent('views.rooms.RoomSettings'));
|
||||
import MatrixClientPeg from '../../../../src/MatrixClientPeg';
|
||||
import SettingsStore from '../../../../src/settings/SettingsStore';
|
||||
|
||||
|
||||
describe.skip('RoomSettings', () => {
|
||||
let parentDiv = null;
|
||||
let client = null;
|
||||
let roomSettings = null;
|
||||
const room = testUtils.mkStubRoom('!DdJkzRliezrwpNebLk:matrix.org');
|
||||
|
||||
function expectSentStateEvent(roomId, eventType, expectedEventContent) {
|
||||
let found = false;
|
||||
for (const call of client.sendStateEvent.mock.calls) {
|
||||
const [
|
||||
actualRoomId,
|
||||
actualEventType,
|
||||
actualEventContent,
|
||||
] = call.slice(0, 3);
|
||||
|
||||
if (roomId === actualRoomId && actualEventType === eventType) {
|
||||
expect(actualEventContent).toEqual(expectedEventContent);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
expect(found).toBe(true);
|
||||
}
|
||||
|
||||
beforeEach(function(done) {
|
||||
testUtils.stubClient();
|
||||
client = MatrixClientPeg.get();
|
||||
client.credentials = {userId: '@me:domain.com'};
|
||||
|
||||
client.setRoomName = jest.fn().mockReturnValue(Promise.resolve());
|
||||
client.setRoomTopic = jest.fn().mockReturnValue(Promise.resolve());
|
||||
client.setRoomDirectoryVisibility = jest.fn().mockReturnValue(Promise.resolve());
|
||||
|
||||
// Covers any room state event (e.g. name, avatar, topic)
|
||||
client.sendStateEvent = jest.fn().mockReturnValue(Promise.resolve());
|
||||
|
||||
// Covers room tagging
|
||||
client.setRoomTag = jest.fn().mockReturnValue(Promise.resolve());
|
||||
client.deleteRoomTag = jest.fn().mockReturnValue(Promise.resolve());
|
||||
|
||||
// Covers any setting in the SettingsStore
|
||||
// (including local client settings not stored via matrix)
|
||||
SettingsStore.setValue = jest.fn().mockReturnValue(Promise.resolve());
|
||||
|
||||
parentDiv = document.createElement('div');
|
||||
document.body.appendChild(parentDiv);
|
||||
|
||||
const gatherWrappedRef = (r) => {roomSettings = r;};
|
||||
|
||||
// get use wrappedRef because we're using wrapInMatrixClientContext
|
||||
ReactDOM.render(
|
||||
<WrappedRoomSettings
|
||||
wrappedRef={gatherWrappedRef}
|
||||
room={room}
|
||||
/>,
|
||||
parentDiv,
|
||||
done,
|
||||
);
|
||||
});
|
||||
|
||||
afterEach((done) => {
|
||||
if (parentDiv) {
|
||||
ReactDOM.unmountComponentAtNode(parentDiv);
|
||||
parentDiv.remove();
|
||||
parentDiv = null;
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
it('should not set when no setting is changed', (done) => {
|
||||
roomSettings.save().then(() => {
|
||||
expect(client.sendStateEvent).not.toHaveBeenCalled();
|
||||
expect(client.setRoomTag).not.toHaveBeenCalled();
|
||||
expect(client.deleteRoomTag).not.toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// XXX: Apparently we do call SettingsStore.setValue
|
||||
xit('should not settings via the SettingsStore when no setting is changed', (done) => {
|
||||
roomSettings.save().then(() => {
|
||||
expect(SettingsStore.setValue).not.toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should set room name when it has changed', (done) => {
|
||||
const name = "My Room Name";
|
||||
roomSettings.setName(name);
|
||||
|
||||
roomSettings.save().then(() => {
|
||||
expect(client.setRoomName.mock.calls[0].slice(0, 2))
|
||||
.toEqual(['!DdJkzRliezrwpNebLk:matrix.org', name]);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should set room topic when it has changed', (done) => {
|
||||
const topic = "this is a topic";
|
||||
roomSettings.setTopic(topic);
|
||||
|
||||
roomSettings.save().then(() => {
|
||||
expect(client.setRoomTopic.mock.calls[0].slice(0, 2))
|
||||
.toEqual(['!DdJkzRliezrwpNebLk:matrix.org', topic]);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should set history visibility when it has changed', (done) => {
|
||||
const historyVisibility = "translucent";
|
||||
roomSettings.setState({
|
||||
history_visibility: historyVisibility,
|
||||
});
|
||||
|
||||
roomSettings.save().then(() => {
|
||||
expectSentStateEvent(
|
||||
"!DdJkzRliezrwpNebLk:matrix.org",
|
||||
"m.room.history_visibility", {history_visibility: historyVisibility},
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// XXX: Can't test this because we `getRoomDirectoryVisibility` in `componentWillMount`
|
||||
xit('should set room directory publicity when set to true', (done) => {
|
||||
const isRoomPublished = true;
|
||||
roomSettings.setState({
|
||||
isRoomPublished,
|
||||
}, () => {
|
||||
roomSettings.save().then(() => {
|
||||
expect(client.setRoomDirectoryVisibility.calls[0].arguments.slice(0, 2))
|
||||
.toEqual("!DdJkzRliezrwpNebLk:matrix.org", isRoomPublished ? "public" : "private");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should set power levels when changed', (done) => {
|
||||
roomSettings.onPowerLevelsChanged(42, "invite");
|
||||
|
||||
roomSettings.save().then(() => {
|
||||
expectSentStateEvent(
|
||||
"!DdJkzRliezrwpNebLk:matrix.org",
|
||||
"m.room.power_levels", { invite: 42 },
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should set event power levels when changed', (done) => {
|
||||
roomSettings.onPowerLevelsChanged(42, "event_levels_m.room.message");
|
||||
|
||||
roomSettings.save().then(() => {
|
||||
// We expect all state events to be set to the state_default (50)
|
||||
// See powerLevelDescriptors in RoomSettings
|
||||
expectSentStateEvent(
|
||||
"!DdJkzRliezrwpNebLk:matrix.org",
|
||||
"m.room.power_levels", {
|
||||
events: {
|
||||
'm.room.message': 42,
|
||||
'm.room.avatar': 50,
|
||||
'm.room.name': 50,
|
||||
'm.room.canonical_alias': 50,
|
||||
'm.room.history_visibility': 50,
|
||||
'm.room.power_levels': 50,
|
||||
'm.room.topic': 50,
|
||||
'im.vector.modular.widgets': 50,
|
||||
},
|
||||
},
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue