Skip to content

Commit

Permalink
[web] Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Mar 16, 2023
1 parent 3e29f10 commit c6810d1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
34 changes: 23 additions & 11 deletions web/src/client/storage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,10 @@ describe("#proposal", () => {
};

describe("#getData", () => {
beforeEach(() => {
beforeEach(async () => {
contexts.withAvailableDevices();
contexts.withProposal();
await client.setUp();
});

it("returns the available devices and the proposal result", async () => {
Expand All @@ -181,8 +182,9 @@ describe("#proposal", () => {
});

describe("#getAvailableDevices", () => {
beforeEach(() => {
beforeEach(async () => {
contexts.withAvailableDevices();
await client.setUp();
});

it("returns the list of available devices", async () => {
Expand All @@ -193,8 +195,9 @@ describe("#proposal", () => {

describe("#getResult", () => {
describe("if there is no proposal yet", () => {
beforeEach(() => {
beforeEach(async () => {
contexts.withoutProposal();
await client.setUp();
});

it("returns undefined", async () => {
Expand All @@ -204,8 +207,10 @@ describe("#proposal", () => {
});

describe("if there is a proposal", () => {
beforeEach(() => {
beforeEach(async () => {
contexts.withProposal();
await client.setUp();

});

it("returns the proposal settings and actions", async () => {
Expand All @@ -216,10 +221,11 @@ describe("#proposal", () => {
});

describe("#calculate", () => {
beforeEach(() => {
beforeEach(async () => {
cockpitProxies.proposalCalculator = {
Calculate: jest.fn()
};
await client.setUp();
});

it("calculates a default proposal when no settings are given", async () => {
Expand Down Expand Up @@ -278,10 +284,11 @@ describe("#proposal", () => {

describe("#iscsi", () => {
describe("#getInitiatorName", () => {
beforeEach(() => {
beforeEach(async () => {
cockpitProxies.iscsiInitiator = {
InitiatorName: "iqn.1996-04.com.suse:01:351e6d6249"
};
await client.setUp();
});

it("returns the current initiator name", async () => {
Expand All @@ -291,10 +298,11 @@ describe("#iscsi", () => {
});

describe("#setInitiatorName", () => {
beforeEach(() => {
beforeEach(async () => {
cockpitProxies.iscsiInitiator = {
InitiatorName: "iqn.1996-04.com.suse:01:351e6d6249"
};
await client.setUp();
});

it("sets the given initiator name", async () => {
Expand All @@ -306,8 +314,9 @@ describe("#iscsi", () => {

describe("#getNodes", () => {
describe("if there is no exported iSCSI nodes yet", () => {
beforeEach(() => {
beforeEach(async () => {
contexts.withoutISCSINodes();
await client.setUp();
});

it("returns an empty list", async () => {
Expand All @@ -317,8 +326,9 @@ describe("#iscsi", () => {
});

describe("if there are exported iSCSI nodes", () => {
beforeEach(() => {
beforeEach(async () => {
contexts.withISCSINodes();
await client.setUp();
});

it("returns a list with the exported iSCSI nodes", async () => {
Expand Down Expand Up @@ -349,10 +359,11 @@ describe("#iscsi", () => {
});

describe("#discover", () => {
beforeEach(() => {
beforeEach(async () => {
cockpitProxies.iscsiInitiator = {
Discover: jest.fn()
};
await client.setUp();
});

it("performs an iSCSI discovery with the given options", async () => {
Expand All @@ -373,10 +384,11 @@ describe("#iscsi", () => {
});

describe("#Delete", () => {
beforeEach(() => {
beforeEach(async () => {
cockpitProxies.iscsiInitiator = {
Delete: jest.fn()
};
await client.setUp();
});

it("deletes the given iSCSI node", async () => {
Expand Down
3 changes: 2 additions & 1 deletion web/src/components/overview/StorageSection.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ beforeEach(() => {
proposal: { getData: jest.fn().mockResolvedValue(proposal) },
getStatus: jest.fn().mockResolvedValue(status),
getValidationErrors: jest.fn().mockResolvedValue(errors),
onStatusChange: onStatusChangeFn
onStatusChange: onStatusChangeFn,
setUp: jest.fn().mockResolvedValue(null)
},
};
});
Expand Down

0 comments on commit c6810d1

Please sign in to comment.