mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-04 08:40:28 +00:00
fix accessor
This commit is contained in:
parent
82179cb397
commit
98e3b6082e
1 changed files with 11 additions and 11 deletions
|
@ -80,6 +80,13 @@ describe("group related statistics tests", () => {
|
|||
let tAPI: UserClient | undefined;
|
||||
const imports = importFileGenerator(TOTAL_ITEMS);
|
||||
|
||||
const api = (): UserClient => {
|
||||
if (!tAPI) {
|
||||
throw new Error("API not initialized");
|
||||
}
|
||||
return tAPI;
|
||||
};
|
||||
|
||||
beforeAll(async () => {
|
||||
// -- Setup --
|
||||
const { client } = await factories.client.singleUse();
|
||||
|
@ -92,17 +99,10 @@ describe("group related statistics tests", () => {
|
|||
expect(setupResp.status).toBe(204);
|
||||
});
|
||||
|
||||
if (!tAPI) {
|
||||
throw new Error("API is not defined");
|
||||
}
|
||||
|
||||
// cast api to concrete type
|
||||
const api = tAPI;
|
||||
|
||||
// Write to file system for debugging
|
||||
// fs.writeFileSync("test.csv", csv);
|
||||
test("Validate Group Statistics", async () => {
|
||||
const { status, data } = await api.stats.group();
|
||||
const { status, data } = await api().stats.group();
|
||||
expect(status).toBe(200);
|
||||
|
||||
expect(data.totalItems).toEqual(TOTAL_ITEMS);
|
||||
|
@ -124,7 +124,7 @@ describe("group related statistics tests", () => {
|
|||
}
|
||||
|
||||
test("Validate Labels Statistics", async () => {
|
||||
const { status, data } = await api.stats.labels();
|
||||
const { status, data } = await api().stats.labels();
|
||||
expect(status).toBe(200);
|
||||
|
||||
for (const label of data) {
|
||||
|
@ -133,7 +133,7 @@ describe("group related statistics tests", () => {
|
|||
});
|
||||
|
||||
test("Validate Locations Statistics", async () => {
|
||||
const { status, data } = await api.stats.locations();
|
||||
const { status, data } = await api().stats.locations();
|
||||
expect(status).toBe(200);
|
||||
|
||||
for (const location of data) {
|
||||
|
@ -142,7 +142,7 @@ describe("group related statistics tests", () => {
|
|||
});
|
||||
|
||||
test("Validate Purchase Over Time", async () => {
|
||||
const { status, data } = await api.stats.totalPriceOverTime();
|
||||
const { status, data } = await api().stats.totalPriceOverTime();
|
||||
expect(status).toBe(200);
|
||||
expect(data.entries.length).toEqual(TOTAL_ITEMS);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue