Compare commits
3 Commits
eac14571e2
...
b800542afa
| Author | SHA1 | Date | |
|---|---|---|---|
|
b800542afa
|
|||
|
678d7e89d2
|
|||
|
387f75a4d3
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "updaterweblibrary",
|
"name": "updaterweblibrary",
|
||||||
"version": "1.0.6",
|
"version": "1.0.7",
|
||||||
"description": "OTA Updater App frontend library",
|
"description": "OTA Updater App frontend library",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ export default class Updater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getRawArchive(): Promise<string> {
|
private async getRawArchive(): Promise<string> {
|
||||||
const res = await fetch(`https://cors.emaker.limited/?url=${this.archiveURL}.${this.feedType}`, {
|
const res = await fetch(`http://cors.emaker.limited/?url=${this.archiveURL}.${this.feedType}`, {
|
||||||
"mode": "cors"
|
// "mode": "cors"
|
||||||
});
|
});
|
||||||
const text = await res.text();
|
const text = await res.text();
|
||||||
return text;
|
return text;
|
||||||
@@ -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") {
|
||||||
|
|||||||
@@ -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 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 updater = new Updater("https://git.emaker.limited/MicrocontrollerCD/SoftwareRelease/releases", "atom");
|
||||||
const res = await updater.getArchive();
|
test("date checked is not current date", async () => {
|
||||||
expect(res).not.toBe(null);
|
const res: versionNotes[] = await updater.getArchive();
|
||||||
expect(res.length).toBeGreaterThan(0);
|
const date: Date = res[0].date as Date;
|
||||||
});
|
const today: Date = new Date;
|
||||||
|
expect(date.getUTCSeconds()).not.toBe(today.getUTCSeconds())
|
||||||
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);
|
|
||||||
});
|
|
||||||
|
|||||||
Reference in New Issue
Block a user