the date retrieved is now correct

This commit is contained in:
2025-10-31 13:14:24 +00:00
parent 387f75a4d3
commit 678d7e89d2
2 changed files with 34 additions and 22 deletions

View File

@@ -31,7 +31,7 @@ export default class Updater {
if (element.name == "title") { if (element.name == "title") {
outEntry.title = (element.children[0] as XmlText).text; outEntry.title = (element.children[0] as XmlText).text;
} }
else if (element.name == "date") { else if (element.name == "updated") {
outEntry.date = new Date((element.children[0] as XmlText).text); outEntry.date = new Date((element.children[0] as XmlText).text);
} }
else if (element.name == "link") { else if (element.name == "link") {

View File

@@ -1,23 +1,35 @@
import { expect, expectTypeOf, test } from "vitest"; import { describe, expect, test } from "vitest";
import Updater from "../src/index.ts"; import Updater, { versionNotes } from "../src/index.ts";
test("get an atom feed from gitea", async (): Promise<void> => { describe("retrieving data", () => {
test("get an atom feed from gitea", async (): Promise<void> => {
const updater = new Updater("https://git.emaker.limited/MicrocontrollerCD/SoftwareRelease/releases", "atom"); const updater = new Updater("https://git.emaker.limited/MicrocontrollerCD/SoftwareRelease/releases", "atom");
const res = await updater.getArchive(); const res = await updater.getArchive();
expect(res).not.toBe(null); expect(res).not.toBe(null);
expect(res.length).toBeGreaterThan(0); expect(res.length).toBeGreaterThan(0);
}); });
test("get an rss feed from gitea", async(): Promise<void> => { test("get an rss feed from gitea", async (): Promise<void> => {
const updater = new Updater("https://git.emaker.limited/MicrocontrollerCD/SoftwareRelease/releases", "rss"); const updater = new Updater("https://git.emaker.limited/MicrocontrollerCD/SoftwareRelease/releases", "rss");
const res = await updater.getArchive(); const res = await updater.getArchive();
expect(res).not.toBe(null); expect(res).not.toBe(null);
expect(res.length).toBeGreaterThan(0); expect(res.length).toBeGreaterThan(0);
}); });
test("get an atom feed from github", async (): Promise<void> => { test("get an atom feed from github", async (): Promise<void> => {
const updater = new Updater("https://github.com/chopster44/Phaser_3_pong/releases", "atom"); const updater = new Updater("https://github.com/chopster44/Phaser_3_pong/releases", "atom");
const res = await updater.getArchive(); const res = await updater.getArchive();
expect(res).not.toBe(null); expect(res).not.toBe(null);
expect(res.length).toBeGreaterThan(0); expect(res.length).toBeGreaterThan(0);
});
}); });
describe("data validation", () => {
const updater = new Updater("https://git.emaker.limited/MicrocontrollerCD/SoftwareRelease/releases", "atom");
test("date checked is not current date", async () => {
const res: versionNotes[] = await updater.getArchive();
const date: Date = res[0].date as Date;
const today: Date = new Date;
expect(date.getUTCSeconds()).not.toBe(today.getUTCSeconds())
})
})