diff --git a/src/index.ts b/src/index.ts index d292227..7a1bea7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,7 +31,7 @@ export default class Updater { if (element.name == "title") { 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); } else if (element.name == "link") { diff --git a/test/archive.test.ts b/test/archive.test.ts index 9fa9c70..f625a7e 100644 --- a/test/archive.test.ts +++ b/test/archive.test.ts @@ -1,23 +1,35 @@ -import { expect, expectTypeOf, test } from "vitest"; -import Updater from "../src/index.ts"; +import { describe, expect, test } from "vitest"; +import Updater, { versionNotes } from "../src/index.ts"; -test("get an atom feed from gitea", async (): Promise => { +describe("retrieving data", () => { + test("get an atom feed from gitea", async (): Promise => { + const updater = new Updater("https://git.emaker.limited/MicrocontrollerCD/SoftwareRelease/releases", "atom"); + const res = await updater.getArchive(); + expect(res).not.toBe(null); + expect(res.length).toBeGreaterThan(0); + }); + + test("get an rss feed from gitea", async (): Promise => { + const updater = new Updater("https://git.emaker.limited/MicrocontrollerCD/SoftwareRelease/releases", "rss"); + const res = await updater.getArchive(); + expect(res).not.toBe(null); + expect(res.length).toBeGreaterThan(0); + }); + + test("get an atom feed from github", async (): Promise => { + const updater = new Updater("https://github.com/chopster44/Phaser_3_pong/releases", "atom"); + const res = await updater.getArchive(); + expect(res).not.toBe(null); + expect(res.length).toBeGreaterThan(0); + }); +}); + +describe("data validation", () => { const updater = new Updater("https://git.emaker.limited/MicrocontrollerCD/SoftwareRelease/releases", "atom"); - const res = await updater.getArchive(); - expect(res).not.toBe(null); - expect(res.length).toBeGreaterThan(0); -}); - -test("get an rss feed from gitea", async(): Promise => { - const updater = new Updater("https://git.emaker.limited/MicrocontrollerCD/SoftwareRelease/releases", "rss"); - const res = await updater.getArchive(); - expect(res).not.toBe(null); - expect(res.length).toBeGreaterThan(0); -}); - -test("get an atom feed from github", async (): Promise => { - const updater = new Updater("https://github.com/chopster44/Phaser_3_pong/releases", "atom"); - const res = await updater.getArchive(); - expect(res).not.toBe(null); - expect(res.length).toBeGreaterThan(0); -}); + 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()) + }) +})