View | Details | Raw Unified | Return to bug 38446
Collapse All | Expand All

(-)a/t/cypress/component/api/additionalFieldsAPIClient.ts (-1 / +27 lines)
Line 0 Link Here
0
- 
1
import AdditionalFieldsAPIClient from "@fetch/additional-fields-api-client";
2
import HttpClient from "@fetch/http-client";
3
4
describe("AdditionalFieldsAPIClientWrapper", () => {
5
    it("Correctly loads the wrapper when called", () => {
6
        const client = new AdditionalFieldsAPIClient(HttpClient);
7
        expect(client).to.have.property("clients");
8
    });
9
    it("Can correctly pick a module based on a resource type", () => {
10
        const client = new AdditionalFieldsAPIClient(HttpClient);
11
        const getModuleName = client.getModuleName;
12
        expect(getModuleName("agreement")).to.eq("erm");
13
        expect(getModuleName("license")).to.eq("erm");
14
        expect(getModuleName("package")).to.eq("erm");
15
        expect(getModuleName()).to.eq("admin");
16
        expect(getModuleName("dummyModule")).to.eq("admin");
17
    });
18
    it("Can correctly call the endpoint for that module", async () => {
19
        const client = new AdditionalFieldsAPIClient(HttpClient);
20
21
        const ermResult = await client.additional_fields.getAll("agreement");
22
        expect(ermResult.url).to.include("v1/erm/extended");
23
24
        const adminResult = await client.additional_fields.getAll();
25
        expect(adminResult.url).to.include("v1/extended");
26
    });
27
});

Return to bug 38446