mirror of https://github.com/vector-im/riot-web
Add test for renderToString
parent
b3c03c9b68
commit
900accd823
|
@ -48,6 +48,7 @@ export default class PlainTextExporter extends Exporter {
|
||||||
|
|
||||||
const match = REPLY_REGEX.exec(content.body);
|
const match = REPLY_REGEX.exec(content.body);
|
||||||
|
|
||||||
|
// if the reply format is invalid, then return the body
|
||||||
if (!match) return content.body;
|
if (!match) return content.body;
|
||||||
|
|
||||||
let rplSource: string;
|
let rplSource: string;
|
||||||
|
|
|
@ -14,13 +14,15 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
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 { MatrixClientPeg } from "../../src/MatrixClientPeg";
|
||||||
import { textForFormat, IExportOptions, ExportTypes } from "../../src/utils/exportUtils/exportUtils";
|
import { textForFormat, IExportOptions, ExportTypes } from "../../src/utils/exportUtils/exportUtils";
|
||||||
import '../skinned-sdk';
|
import '../skinned-sdk';
|
||||||
import PlainTextExporter from "../../src/utils/exportUtils/PlainTextExport";
|
import PlainTextExporter from "../../src/utils/exportUtils/PlainTextExport";
|
||||||
|
import HTMLExporter from "../../src/utils/exportUtils/HtmlExport";
|
||||||
import * as TestUtilsMatrix from '../test-utils';
|
import * as TestUtilsMatrix from '../test-utils';
|
||||||
import { stubClient } from '../test-utils';
|
import { stubClient } from '../test-utils';
|
||||||
|
import { renderToString } from "react-dom/server";
|
||||||
|
|
||||||
let client: MatrixClient;
|
let client: MatrixClient;
|
||||||
|
|
||||||
|
@ -65,9 +67,8 @@ describe('export', function() {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const events = mkEvents();
|
const events: MatrixEvent[] = mkEvents();
|
||||||
const room = createRoom();
|
const room = createRoom();
|
||||||
console.log(events);
|
|
||||||
function createRoom() {
|
function createRoom() {
|
||||||
const room = new Room(generateRoomId(), null, client.getUserId());
|
const room = new Room(generateRoomId(), null, client.getUserId());
|
||||||
return room;
|
return room;
|
||||||
|
@ -131,7 +132,7 @@ describe('export', function() {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"msgtype": "m.text",
|
"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",
|
"body": "Invalid reply format",
|
||||||
"expectedText": "Invalid reply format",
|
"expectedText": "Invalid reply format",
|
||||||
},
|
},
|
||||||
|
@ -151,5 +152,13 @@ describe('export', function() {
|
||||||
expect(exporter.textForReplyEvent(content)).toBe(content.expectedText);
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue