Skip to content

Commit

Permalink
Add client unit test for edit dataset error
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed May 21, 2024
1 parent d6087e5 commit 5bd9fed
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions client/src/components/DatasetInformation/DatasetAttributes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,31 @@ async function buildWrapper(conversion_disable = false) {
return wrapper;
}

async function buildWrapperWithError(error) {
const wrapper = mount(DatasetAttributes, {
propsData: {
datasetId: "dataset_id",
messageText: error,
messageVariant: "danger",
},
computed: {
hasError() {
return true;
},
},
localVue,
stubs: {
DatasetAttributesProvider: MockProvider({
result: null,
}),
FontAwesomeIcon: false,
FormElement: false,
},
});
await flushPromises();
return wrapper;
}

describe("DatasetAttributes", () => {
it("check rendering", async () => {
const axiosMock = new MockAdapter(axios);
Expand Down Expand Up @@ -61,4 +86,15 @@ describe("DatasetAttributes", () => {
expect(wrapper.findAll(".tab-pane").length).toBe(3);
expect(wrapper.findAll(".ui-portlet-section").length).toBe(1);
});

it("doesn't render edit controls with error", async () => {
const wrapper = await buildWrapperWithError("error");
expect(wrapper.findAll("button").length).toBe(0);
expect(wrapper.findAll("#attribute_text").length).toBe(0);
expect(wrapper.findAll("#conversion_text").length).toBe(0);
expect(wrapper.findAll("#datatype_text").length).toBe(0);
expect(wrapper.findAll("#permission_text").length).toBe(0);
expect(wrapper.findAll(".tab-pane").length).toBe(0);
expect(wrapper.findAll(".ui-portlet-section").length).toBe(0);
});
});

0 comments on commit 5bd9fed

Please sign in to comment.