mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Parsing app release date from the package version
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
c9f105405f
commit
c2c9c93b54
@ -3,12 +3,17 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import type { DiContainer } from "@ogre-tools/injectable";
|
||||||
import appVersionInjectable from "../../../common/get-configuration-file-model/app-version/app-version.injectable";
|
import appVersionInjectable from "../../../common/get-configuration-file-model/app-version/app-version.injectable";
|
||||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||||
import appPublishDateInjectable from "../app-publish-date.injectable";
|
import appPublishDateInjectable from "../app-publish-date.injectable";
|
||||||
|
|
||||||
describe("appPublishDate", () => {
|
describe("appPublishDate", () => {
|
||||||
const di = getDiForUnitTesting({ doGeneralOverrides: true });
|
let di: DiContainer;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||||
|
});
|
||||||
|
|
||||||
it("should return empty string if appVersion is not provided", () => {
|
it("should return empty string if appVersion is not provided", () => {
|
||||||
di.override(appVersionInjectable, () => "");
|
di.override(appVersionInjectable, () => "");
|
||||||
@ -17,4 +22,28 @@ describe("appPublishDate", () => {
|
|||||||
|
|
||||||
expect(appPublishDate).toBe("");
|
expect(appPublishDate).toBe("");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should return empty string if version without date provided", () => {
|
||||||
|
di.override(appVersionInjectable, () => "5.6.0-alpha.0");
|
||||||
|
|
||||||
|
const appPublishDate = di.inject(appPublishDateInjectable);
|
||||||
|
|
||||||
|
expect(appPublishDate).toBe("");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return empty string if invalid version date provided", () => {
|
||||||
|
di.override(appVersionInjectable, () => "5.6.0-alpha.2021-23-1.0");
|
||||||
|
|
||||||
|
const appPublishDate = di.inject(appPublishDateInjectable);
|
||||||
|
|
||||||
|
expect(appPublishDate).toBe("");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should return proper date if version with date provided", () => {
|
||||||
|
di.override(appVersionInjectable, () => "5.4.6-latest.20220428.1");
|
||||||
|
|
||||||
|
const appPublishDate = di.inject(appPublishDateInjectable);
|
||||||
|
|
||||||
|
expect(appPublishDate).toBe("2022-04-28");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,6 +3,15 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function appPublishDate(appVersion: string) {
|
import moment from "moment";
|
||||||
return "";
|
|
||||||
|
export function appPublishDate(appVersion = "") {
|
||||||
|
const dateFromVersion = appVersion.match(/\d{8}/);
|
||||||
|
const date = moment(dateFromVersion?.[0], "YYYYMMDD");
|
||||||
|
|
||||||
|
if (!date.isValid()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return date.format("YYYY-MM-DD");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user