diff --git a/src/utils/exportUtils/PlainTextExport.ts b/src/utils/exportUtils/PlainTextExport.ts index 7421118470..86f714140e 100644 --- a/src/utils/exportUtils/PlainTextExport.ts +++ b/src/utils/exportUtils/PlainTextExport.ts @@ -48,6 +48,7 @@ export default class PlainTextExporter extends Exporter { const match = REPLY_REGEX.exec(content.body); + // if the reply format is invalid, then return the body if (!match) return content.body; let rplSource: string; diff --git a/test/utils/export-test.tsx b/test/utils/export-test.tsx index 141fbe1280..1b8fc9c31b 100644 --- a/test/utils/export-test.tsx +++ b/test/utils/export-test.tsx @@ -14,13 +14,15 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { IContent, MatrixClient, Room } from "matrix-js-sdk"; +import { IContent, MatrixClient, MatrixEvent, Room } from "matrix-js-sdk"; import { MatrixClientPeg } from "../../src/MatrixClientPeg"; import { textForFormat, IExportOptions, ExportTypes } from "../../src/utils/exportUtils/exportUtils"; import '../skinned-sdk'; import PlainTextExporter from "../../src/utils/exportUtils/PlainTextExport"; +import HTMLExporter from "../../src/utils/exportUtils/HtmlExport"; import * as TestUtilsMatrix from '../test-utils'; import { stubClient } from '../test-utils'; +import { renderToString } from "react-dom/server"; let client: MatrixClient; @@ -65,9 +67,8 @@ describe('export', function() { }, ]; - const events = mkEvents(); + const events: MatrixEvent[] = mkEvents(); const room = createRoom(); - console.log(events); function createRoom() { const room = new Room(generateRoomId(), null, client.getUserId()); return room; @@ -131,7 +132,7 @@ describe('export', function() { }, { "msgtype": "m.text", - // if the reply format is invalid, then return the original string as it is + // if the reply format is invalid, then return the body "body": "Invalid reply format", "expectedText": "Invalid reply format", }, @@ -151,5 +152,13 @@ describe('export', function() { expect(exporter.textForReplyEvent(content)).toBe(content.expectedText); } }); + + it('checks if the render to string works for eventTile', function() { + // Todo: Generate different event types + const exporter = new HTMLExporter(room, ExportTypes.BEGINNING, mockExportOptions, null); + for (const event of events) { + expect(renderToString(exporter.getEventTile(event, false))).toBeTruthy(); + } + }); });