From 1fc425a0e7b5df476caed48ea83904544caf4a8f Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 18 Oct 2024 11:51:49 +0100 Subject: [PATCH] Improve coverage Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .../views/dialogs/ChangelogDialog-test.tsx | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/unit-tests/components/views/dialogs/ChangelogDialog-test.tsx b/test/unit-tests/components/views/dialogs/ChangelogDialog-test.tsx index e16abb0e83e..ccc4c574f03 100644 --- a/test/unit-tests/components/views/dialogs/ChangelogDialog-test.tsx +++ b/test/unit-tests/components/views/dialogs/ChangelogDialog-test.tsx @@ -10,7 +10,7 @@ import React from "react"; import fetchMock from "fetch-mock-jest"; import { render, screen, waitForElementToBeRemoved } from "jest-matrix-react"; -import ChangelogDialog from "../../../../../src/components/views/dialogs/ChangelogDialog"; +import ChangelogDialog, { parseVersion } from "../../../../../src/components/views/dialogs/ChangelogDialog"; describe("", () => { it("should fetch github proxy url for each repo with old and new version strings", async () => { @@ -78,3 +78,24 @@ describe("", () => { expect(asFragment()).toMatchSnapshot(); }); }); + +describe("parseVersion", () => { + it("should return null for old-style version strings", () => { + expect(parseVersion("aaaabbbb-react-ccccdddd-js-eeeeffff")).toBeNull(); + }); + + it("should return null for invalid version strings", () => { + expect(parseVersion("aaaabbbb-react-ccccdddd")).toBeNull(); + }); + + it("should return null for release version strings", () => { + expect(parseVersion("v1.22.33")).toBeNull(); + }); + + it("should return mapping for develop version string", () => { + expect(parseVersion("aaaabbbb-js-eeeeffff")).toEqual({ + "element-hq/element-web": "aaaabbbb", + "matrix-org/matrix-js-sdk": "eeeeffff", + }); + }); +});