Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aminlatifi committed Sep 2, 2024
1 parent a683895 commit a64d441
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/controllers/utils/types.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { orgCountTuplesTypes } from "./types";

describe.only("parse database query", () => {
describe("parse database query", () => {
it("should parse project stats query", () => {
const raw = `{"(0x2e22df9a11e06c306ed8f64ca45ceae02efcf8a443371395a78371bc4fb6f722,1)","(0xf63f2a7159ee674aa6fce42196a8bb0605eafcf20c19e91a7eafba8d39fa0404,1)"}`;

Expand Down
27 changes: 25 additions & 2 deletions src/test/store.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { describe, expect, test, afterAll } from "@jest/globals";
import { closeConnection, getTestCtx } from "./utils";
import { closeConnection, getTestCtx, getTestEntityManager } from "./utils";
import { Organisation } from "../model";

describe("simple storage", () => {
beforeAll(async () => {
const em = await getTestEntityManager();
await em.getRepository(Organisation).delete({});
});
afterAll(async () => {
await closeConnection();
});

test("sample authorized attest", async () => {
test("should save sample authorized attest", async () => {
const ctx = await getTestCtx();
const organization = new Organisation({
id: "schemaUid",
Expand All @@ -24,4 +28,23 @@ describe("simple storage", () => {
expect(fetchOrganization).toBeDefined();
expect(fetchOrganization?.name).toBe("name");
});

test("should not fail on upserting the same entity", async () => {
const ctx = await getTestCtx();
const organization = new Organisation({
id: "schemaUid",
name: "name",
issuer: "issuer",
});

await ctx.store.upsert(organization);
await ctx.store.upsert(organization);

const fetchOrganization = await ctx.store.findOneBy(Organisation, {
name: "name",
});

expect(fetchOrganization).toBeDefined();
expect(fetchOrganization?.name).toBe("name");
});
});

0 comments on commit a64d441

Please sign in to comment.