chore: add tests for schema and API config mocking
- Added unit tests for schema loader, mocking Config variables and resolvers. - Added unit tests for Zabbix API configuration, verifying constants derived from Config. - Mocked relevant modules and filesystem behaviors to enable isolated testing. - Optimized imports on all files and include this within a new .junie/guidelines.md file
This commit is contained in:
parent
5e41aa5cc4
commit
7adaf82c1b
23 changed files with 204 additions and 110 deletions
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import {createResolvers} from "../api/resolvers.js";
|
||||
import {zabbixAPI} from "../datasources/zabbix-api.js";
|
||||
|
||||
|
|
@ -10,6 +9,13 @@ jest.mock("../datasources/zabbix-api.js", () => ({
|
|||
}
|
||||
}));
|
||||
|
||||
// Mocking Config
|
||||
jest.mock("../common_utils.js", () => ({
|
||||
Config: {
|
||||
API_VERSION: "1.2.3"
|
||||
}
|
||||
}));
|
||||
|
||||
describe("Miscellaneous Resolvers", () => {
|
||||
let resolvers: any;
|
||||
|
||||
|
|
@ -20,13 +26,7 @@ describe("Miscellaneous Resolvers", () => {
|
|||
|
||||
test("apiVersion query", async () => {
|
||||
const result = await resolvers.Query.apiVersion();
|
||||
expect(typeof result).toBe("string");
|
||||
});
|
||||
|
||||
test("zabbixVersion query", async () => {
|
||||
(zabbixAPI.post as jest.Mock).mockResolvedValueOnce({ result: "7.0.0" });
|
||||
const result = await resolvers.Query.zabbixVersion();
|
||||
expect(zabbixAPI.post).toHaveBeenCalledWith("apiinfo.version", expect.anything());
|
||||
expect(result).toBe("1.2.3");
|
||||
});
|
||||
|
||||
test("login query", async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue