You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-07 21:23:00 +03:00
Remove dead & duplicated code (#11405)
* Remove dead code * Make dead code happier * DRY pickle additional data calculation * Iterate
This commit is contained in:
committed by
GitHub
parent
672ad98ec7
commit
27d79458da
@@ -12,6 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { EventEmitter } from "events";
|
||||
import { Room, RoomMember, EventType, MatrixEvent } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { MatrixClientPeg } from "../../../src/MatrixClientPeg";
|
||||
@@ -87,6 +89,26 @@ describe("Permalinks", function () {
|
||||
jest.spyOn(MatrixClientPeg, "get").mockRestore();
|
||||
});
|
||||
|
||||
it("should not clean up listeners even if start was called multiple times", () => {
|
||||
const room = mockRoom("!fake:example.org", []);
|
||||
const getListenerCount = (emitter: EventEmitter) =>
|
||||
emitter
|
||||
.eventNames()
|
||||
.map((e) => emitter.listenerCount(e))
|
||||
.reduce((a, b) => a + b, 0);
|
||||
const listenerCountBefore = getListenerCount(room.currentState);
|
||||
|
||||
const creator = new RoomPermalinkCreator(room);
|
||||
creator.start();
|
||||
creator.start();
|
||||
creator.start();
|
||||
creator.start();
|
||||
expect(getListenerCount(room.currentState)).toBeGreaterThan(listenerCountBefore);
|
||||
|
||||
creator.stop();
|
||||
expect(getListenerCount(room.currentState)).toBe(listenerCountBefore);
|
||||
});
|
||||
|
||||
it("should pick no candidate servers when the room has no members", function () {
|
||||
const room = mockRoom("!fake:example.org", []);
|
||||
const creator = new RoomPermalinkCreator(room);
|
||||
|
Reference in New Issue
Block a user