Remove dead & duplicated code (#11405)
* Remove dead code * Make dead code happier * DRY pickle additional data calculation * Iterate
This commit is contained in:
parent
672ad98ec7
commit
27d79458da
25 changed files with 50 additions and 201 deletions
|
@ -31,7 +31,6 @@ describe("transforming search term", () => {
|
|||
eventId: "",
|
||||
userId: "",
|
||||
viaServers: [],
|
||||
sigil: "",
|
||||
});
|
||||
|
||||
expect(transformSearchTerm(roomLink)).toBe(parsedPermalink);
|
||||
|
@ -46,7 +45,6 @@ describe("transforming search term", () => {
|
|||
eventId: null,
|
||||
userId: null,
|
||||
viaServers: null,
|
||||
sigil: "?",
|
||||
});
|
||||
|
||||
expect(transformSearchTerm(searchTerm)).toBe(searchTerm);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue