You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.4 KiB
TypeScript

import { beforeEach, describe, expect, it } from "bun:test";
import { ApplicationUpdateStarted } from "./events/ApplicationUpdateStarted";
import { TestApp } from "./testing/TestApp";
describe("AppQueries", () => {
describe("pendingApplicationUpdates", () => {
let app: TestApp;
beforeEach(() => {
app = new TestApp([
new ApplicationUpdateStarted(
{ id: "mail", newVersion: "1.0.0" },
new Date()
),
new ApplicationUpdateStarted(
{ id: "blog", newVersion: "10.0.1" },
new Date()
),
]);
});
it("should return an empty array when there are no pending updates", () => {
const app = new TestApp();
expect(app.queries.pendingApplicationUpdates()).toEqual([]);
});
it("should return all pending updates when no appName is provided", () => {
expect(app.queries.pendingApplicationUpdates()).toEqual([
{ id: "mail", newVersion: "1.0.0" },
{ id: "blog", newVersion: "10.0.1" },
]);
});
it("should return all pending updates for the provided application", () => {
expect(app.queries.pendingApplicationUpdates("mail")).toEqual([
{ id: "mail", newVersion: "1.0.0" },
]);
});
it("should return an empty array when there are no pending updates for the provided appName", () => {
expect(app.queries.pendingApplicationUpdates("unknown")).toEqual([]);
});
});
});