Compare commits

...

3 Commits

Author SHA1 Message Date
b800542afa (1.0.7) functional feed retrieval 2025-10-31 13:16:01 +00:00
678d7e89d2 the date retrieved is now correct 2025-10-31 13:14:24 +00:00
387f75a4d3 use cors proxy correctly 2025-10-31 12:20:30 +00:00
3 changed files with 37 additions and 25 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "updaterweblibrary",
"version": "1.0.6",
"version": "1.0.7",
"description": "OTA Updater App frontend library",
"repository": {
"type": "git",

View File

@@ -16,8 +16,8 @@ export default class Updater {
}
private async getRawArchive(): Promise<string> {
const res = await fetch(`https://cors.emaker.limited/?url=${this.archiveURL}.${this.feedType}`, {
"mode": "cors"
const res = await fetch(`http://cors.emaker.limited/?url=${this.archiveURL}.${this.feedType}`, {
// "mode": "cors"
});
const text = await res.text();
return text;
@@ -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") {

View File

@@ -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<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 res = await updater.getArchive();
expect(res).not.toBe(null);
expect(res.length).toBeGreaterThan(0);
});
test("get an rss feed from gitea", async (): Promise<void> => {
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<void> => {
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<void> => {
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<void> => {
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())
})
})