Kill off enzyme in preference of react testing library (#10255)

This commit is contained in:
Michael Telatynski 2023-03-06 15:17:46 +00:00 committed by GitHub
parent 394bffbae4
commit bda54a8b20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 123 additions and 447 deletions

View file

@ -186,7 +186,7 @@ class EmojiPicker extends React.Component<IProps, IState> {
private onChangeFilter = (filter: string): void => {
const lcFilter = filter.toLowerCase().trim(); // filter is case insensitive
for (const cat of this.categories) {
let emojis;
let emojis: IEmoji[];
// If the new filter string includes the old filter string, we don't have to re-filter the whole dataset.
if (lcFilter.includes(this.state.filter)) {
emojis = this.memoizedDataByCategory[cat.id];

View file

@ -43,6 +43,8 @@ interface IState {
export default class MLocationBody extends React.Component<IBodyProps, IState> {
public static contextType = MatrixClientContext;
public context!: React.ContextType<typeof MatrixClientContext>;
private unmounted = false;
private mapId: string;
private reconnectedListener: ClientEventHandlerMap[ClientEvent.Sync];
@ -80,11 +82,15 @@ export default class MLocationBody extends React.Component<IBodyProps, IState> {
};
private onError = (error: Error): void => {
if (this.unmounted) return;
this.setState({ error });
// Unregister first in case we already had it registered
this.context.off(ClientEvent.Sync, this.reconnectedListener);
this.context.on(ClientEvent.Sync, this.reconnectedListener);
};
public componentWillUnmount(): void {
this.unmounted = true;
this.context.off(ClientEvent.Sync, this.reconnectedListener);
}