Bug 38446: Add a unit test for the additional fields wrapper

Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Matt Blenkinsop 2025-11-06 11:38:45 +00:00 committed by Lucas Gass
parent e0ca94ae18
commit a9c1583675
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,27 @@
import AdditionalFieldsAPIClient from "@fetch/additional-fields-api-client";
import HttpClient from "@fetch/http-client";
describe("AdditionalFieldsAPIClientWrapper", () => {
it("Correctly loads the wrapper when called", () => {
const client = new AdditionalFieldsAPIClient(HttpClient);
expect(client).to.have.property("clients");
});
it("Can correctly pick a module based on a resource type", () => {
const client = new AdditionalFieldsAPIClient(HttpClient);
const getModuleName = client.getModuleName;
expect(getModuleName("agreement")).to.eq("erm");
expect(getModuleName("license")).to.eq("erm");
expect(getModuleName("package")).to.eq("erm");
expect(getModuleName()).to.eq("admin");
expect(getModuleName("dummyModule")).to.eq("admin");
});
it("Can correctly call the endpoint for that module", async () => {
const client = new AdditionalFieldsAPIClient(HttpClient);
const ermResult = await client.additional_fields.getAll("agreement");
expect(ermResult.url).to.include("v1/erm/extended");
const adminResult = await client.additional_fields.getAll();
expect(adminResult.url).to.include("v1/extended");
});
});