Skip to content

Commit 9d73749

Browse files
authored
refactor: use reuse lib for running the ui5 version check (#22)
* feat: replace main logic with ui5-version-check lib * docs: update badge links to own repository * feat: run version check via reuse lib * test: adjust test cases * bump version * chore: bundle src
1 parent ba7b7d9 commit 9d73749

15 files changed

+730
-1672
lines changed

__fixtures__/core.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export function mockCoreWithEmptyImpl() {
1717
summary.write = jest.spyOn(core.summary, "write").mockImplementation(() => Promise.resolve(undefined) as any);
1818

1919
const mock = {
20+
getBooleanInput: jest.spyOn(core, "getBooleanInput").mockImplementation(() => true),
2021
info: jest.spyOn(core, "info").mockImplementation(() => {}),
2122
error: jest.spyOn(core, "error").mockImplementation(() => {}),
2223
debug: jest.spyOn(core, "debug").mockImplementation(() => {}),

__tests__/main.test.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { jest } from "@jest/globals";
22
import { mockCoreWithEmptyImpl } from "../__fixtures__/core";
33
import { run } from "../src/main";
4-
import * as ui5VersionCheck from "../src/lib/ui5-version-check";
4+
import * as ui5VersionCheck from "ui5-version-check";
55
import * as utils from "../src/lib/utils";
66

77
describe("main.ts", () => {
@@ -28,9 +28,19 @@ describe("main.ts", () => {
2828
jest.spyOn(utils, "getRepoPath").mockReturnValueOnce(__dirname);
2929
jest.spyOn(utils, "getInputAsArray").mockReturnValueOnce(["sample-project/app/**/webapp"]);
3030
// eslint-disable-next-line @typescript-eslint/no-explicit-any
31-
jest.spyOn(ui5VersionCheck as any, "UI5VersionChecker").mockImplementation(() => ({
31+
jest.spyOn(ui5VersionCheck as any, "UI5VersionCheck").mockImplementation(() => ({
3232
run: jest.fn(),
33-
printSummary: jest.fn()
33+
updatedFiles: ["sample-project/app/admin/webapp/manifest.json"],
34+
summary: [
35+
<ui5VersionCheck.ManifestCheckSummary>{
36+
relPath: "sample-project/app/admin/webapp/manifest.json",
37+
oldVers: "1.55",
38+
newVers: "1.135.*",
39+
status: "ok",
40+
statusIcon: "✅",
41+
statusText: "Version has been successfully updated"
42+
}
43+
]
3444
}));
3545

3646
await expect(run()).resolves.toBeUndefined();
@@ -62,9 +72,10 @@ describe("main.ts", () => {
6272
jest.spyOn(utils, "getRepoPath").mockReturnValueOnce(__dirname);
6373
jest.spyOn(utils, "getInputAsArray").mockReturnValueOnce(["sample-project/app/**/webapp"]);
6474
// eslint-disable-next-line @typescript-eslint/no-explicit-any
65-
jest.spyOn(ui5VersionCheck as any, "UI5VersionChecker").mockImplementation(() => ({
75+
jest.spyOn(ui5VersionCheck as any, "UI5VersionCheck").mockImplementation(() => ({
6676
run: jest.fn(),
67-
printSummary: jest.fn(),
77+
updatedFiles: [],
78+
summary: [],
6879
get hasErrors() {
6980
return true;
7081
}
@@ -81,9 +92,9 @@ describe("main.ts", () => {
8192
jest.spyOn(utils, "getRepoPath").mockReturnValueOnce(__dirname);
8293
jest.spyOn(utils, "getInputAsArray").mockReturnValueOnce(["sample-project/app/**/webapp"]);
8394
// eslint-disable-next-line @typescript-eslint/no-explicit-any
84-
jest.spyOn(ui5VersionCheck as any, "UI5VersionChecker").mockImplementation(() => ({
95+
jest.spyOn(ui5VersionCheck as any, "UI5VersionCheck").mockImplementation(() => ({
8596
run: () => Promise.reject(new Error("Version fetch failed!")),
86-
printSummary: jest.fn(),
97+
// printSummary: jest.fn(),
8798
get hasErrors() {
8899
return true;
89100
}

__tests__/manifest.test.ts

Lines changed: 0 additions & 112 deletions
This file was deleted.

__tests__/ui5-version-api.test.ts

Lines changed: 0 additions & 213 deletions
This file was deleted.

0 commit comments

Comments
 (0)