1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-31 13:44:28 +03:00

Update tests to prefer RTL over Enzyme (#10247

* Update tests to prefer RTL over Enzyme

* Strict types
This commit is contained in:
Michael Telatyński
2023-02-28 08:58:23 +00:00
committed by GitHub
parent dd6fc124d7
commit f40d15388c
20 changed files with 1095 additions and 632 deletions

View File

@ -30,7 +30,7 @@ describe("DMRoomMap", () => {
"user@example.com": [roomId1, roomId2],
"@user:example.com": [roomId1, roomId3, roomId4],
"@user2:example.com": [] as string[],
} satisfies IContent;
} as IContent;
let client: Mocked<MatrixClient>;
let dmRoomMap: DMRoomMap;

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { renderToString } from "react-dom/server";
import { render } from "@testing-library/react";
import {
IContent,
MatrixClient,
@ -227,6 +227,10 @@ describe("export", function () {
return matrixEvents;
}
function renderToString(elem: JSX.Element): string {
return render(elem).container.outerHTML;
}
it("checks if the export format is valid", function () {
function isValidFormat(format: string): boolean {
const options: string[] = Object.values(ExportFormat);
@ -255,7 +259,7 @@ describe("export", function () {
},
setProgressText,
);
const imageRegex = /<img.+ src="mxc:\/\/test.org" alt="image.png"\/>/;
const imageRegex = /<img.+ src="mxc:\/\/test.org" alt="image\.png"\/?>/;
expect(imageRegex.test(renderToString(exporter.getEventTile(mkImageEvent(), true)))).toBeTruthy();
});