Fix develop changelog parsing (#28232)
* Fix develop changelog parsing and DRY it Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * duh Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Improve coverage Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Typeguards! Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Discard changes to test/unit-tests/components/views/dialogs/__snapshots__/ChangelogDialog-test.tsx.snap --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
6771bd6de2
commit
06d1239608
3 changed files with 57 additions and 23 deletions
|
@ -10,7 +10,10 @@ 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, {
|
||||
DevelopVersionString,
|
||||
parseVersion,
|
||||
} from "../../../../../src/components/views/dialogs/ChangelogDialog";
|
||||
|
||||
describe("<ChangelogDialog />", () => {
|
||||
it("should fetch github proxy url for each repo with old and new version strings", async () => {
|
||||
|
@ -64,8 +67,8 @@ describe("<ChangelogDialog />", () => {
|
|||
files: [],
|
||||
});
|
||||
|
||||
const newVersion = "newsha1-js-newsha3";
|
||||
const oldVersion = "oldsha1-js-oldsha3";
|
||||
const newVersion = "newsha1-js-newsha3" as DevelopVersionString;
|
||||
const oldVersion = "oldsha1-js-oldsha3" as DevelopVersionString;
|
||||
const { asFragment } = render(
|
||||
<ChangelogDialog newVersion={newVersion} version={oldVersion} onFinished={jest.fn()} />,
|
||||
);
|
||||
|
@ -78,3 +81,24 @@ describe("<ChangelogDialog />", () => {
|
|||
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",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue