Update tests to expect LinkPreviewGroup behaviour
This commit is contained in:
parent
e3e7d41d5c
commit
f5f4be88f0
1 changed files with 9 additions and 10 deletions
|
@ -22,8 +22,10 @@ import sdk from "../../../skinned-sdk";
|
||||||
import { mkEvent, mkStubRoom } from "../../../test-utils";
|
import { mkEvent, mkStubRoom } from "../../../test-utils";
|
||||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||||
import * as languageHandler from "../../../../src/languageHandler";
|
import * as languageHandler from "../../../../src/languageHandler";
|
||||||
|
import * as TestUtils from "../../../test-utils";
|
||||||
|
|
||||||
const TextualBody = sdk.getComponent("views.messages.TextualBody");
|
const _TextualBody = sdk.getComponent("views.messages.TextualBody");
|
||||||
|
const TextualBody = TestUtils.wrapInMatrixClientContext(_TextualBody);
|
||||||
|
|
||||||
configure({ adapter: new Adapter() });
|
configure({ adapter: new Adapter() });
|
||||||
|
|
||||||
|
@ -305,10 +307,9 @@ describe("<TextualBody />", () => {
|
||||||
const wrapper = mount(<TextualBody mxEvent={ev} showUrlPreview={true} onHeightChanged={() => {}} />);
|
const wrapper = mount(<TextualBody mxEvent={ev} showUrlPreview={true} onHeightChanged={() => {}} />);
|
||||||
expect(wrapper.text()).toBe(ev.getContent().body);
|
expect(wrapper.text()).toBe(ev.getContent().body);
|
||||||
|
|
||||||
let widgets = wrapper.find("LinkPreviewWidget");
|
let widgets = wrapper.find("LinkPreviewGroup");
|
||||||
// at this point we should have exactly one widget
|
// at this point we should have exactly one link
|
||||||
expect(widgets.length).toBe(1);
|
expect(widgets.at(0).prop("links")).toEqual(["https://matrix.org/"]);
|
||||||
expect(widgets.at(0).prop("link")).toBe("https://matrix.org/");
|
|
||||||
|
|
||||||
// simulate an event edit and check the transition from the old URL preview to the new one
|
// simulate an event edit and check the transition from the old URL preview to the new one
|
||||||
const ev2 = mkEvent({
|
const ev2 = mkEvent({
|
||||||
|
@ -333,11 +334,9 @@ describe("<TextualBody />", () => {
|
||||||
|
|
||||||
// XXX: this is to give TextualBody enough time for state to settle
|
// XXX: this is to give TextualBody enough time for state to settle
|
||||||
wrapper.setState({}, () => {
|
wrapper.setState({}, () => {
|
||||||
widgets = wrapper.find("LinkPreviewWidget");
|
widgets = wrapper.find("LinkPreviewGroup");
|
||||||
// at this point we should have exactly two widgets (not the matrix.org one anymore)
|
// at this point we should have exactly two links (not the matrix.org one anymore)
|
||||||
expect(widgets.length).toBe(2);
|
expect(widgets.at(0).prop("links")).toEqual(["https://vector.im/", "https://riot.im/"]);
|
||||||
expect(widgets.at(0).prop("link")).toBe("https://vector.im/");
|
|
||||||
expect(widgets.at(1).prop("link")).toBe("https://riot.im/");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue