Skip to content

Commit

Permalink
add test cases for attestation routing
Browse files Browse the repository at this point in the history
  • Loading branch information
kadamidev committed Jun 13, 2024
1 parent 841b096 commit bd15b3d
Showing 1 changed file with 96 additions and 0 deletions.
96 changes: 96 additions & 0 deletions test/basics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,101 @@ describe("dPID resolution", function () {
assert.equal(value, expected, "incorrect resolution");
});
});
it("should handle a generic attestations route", async () => {
await request(app)
.get("/46/attestations")
.expect(302)
.then((res) => {
const value = res.header["location"];

const expected = "https://nodes.desci.com/dpid/46/attestations";
assert.equal(value, expected, "incorrect resolution");
})
.catch((err) => {
if (err) {
assert.fail(err);
}
});
});
it("should handle a versioned(V) generic attestations route", async () => {
await request(app)
.get("/46/v2/attestations")
.expect(302)
.then((res) => {
const value = res.header["location"];

const expected = "https://nodes.desci.com/dpid/46/v2/attestations";
assert.equal(value, expected, "incorrect resolution");
})
.catch((err) => {
if (err) {
assert.fail(err);
}
});
});
it("should handle a versioned(I) generic attestations route", async () => {
await request(app)
.get("/46/2/attestations")
.expect(302)
.then((res) => {
const value = res.header["location"];

const expected = "https://nodes.desci.com/dpid/46/v3/attestations";
assert.equal(value, expected, "incorrect resolution");
})
.catch((err) => {
if (err) {
assert.fail(err);
}
});
});
it("should handle a specific attestations route with an attestation slug", async () => {
await request(app)
.get("/46/attestations/scientific-manuscript")
.expect(302)
.then((res) => {
const value = res.header["location"];

const expected = "https://nodes.desci.com/dpid/46";
assert.equal(value, expected, "incorrect resolution");
})
.catch((err) => {
if (err) {
assert.fail(err);
}
});
});
it("should handle a versioned(V) attestations route with an attestation slug", async () => {
await request(app)
.get("/46/v2/attestations/scientific-manuscript")
.expect(302)
.then((res) => {
const value = res.header["location"];

const expected = "https://nodes.desci.com/dpid/46/v2/attestations/scientific-manuscript";
assert.equal(value, expected, "incorrect resolution");
})
.catch((err) => {
if (err) {
assert.fail(err);
}
});
});
it("should handle a versioned(I) attestations route with an attestation slug", async () => {
await request(app)
.get("/46/2/attestations/scientific-manuscript")
.expect(302)
.then((res) => {
const value = res.header["location"];

const expected = "https://nodes.desci.com/dpid/46/v3/attestations/scientific-manuscript";
assert.equal(value, expected, "incorrect resolution");
})
.catch((err) => {
if (err) {
assert.fail(err);
}
});
});
});
});

0 comments on commit bd15b3d

Please sign in to comment.