Skip to content

Commit e417640

Browse files
committed
testing
1 parent b1a8ced commit e417640

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

src/components/Menus/Sidebar/Sidebar.test.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,3 +316,93 @@ describe("When the project has no instructions", () => {
316316
});
317317
});
318318
});
319+
320+
describe("When plugins are provided", () => {
321+
const initialState = {
322+
editor: {
323+
project: {
324+
components: [],
325+
image_list: [],
326+
},
327+
instructionsEditable: false,
328+
},
329+
instructions: {},
330+
};
331+
const mockStore = configureStore([]);
332+
const store = mockStore(initialState);
333+
const defaultPlugin = {
334+
name: "my-amazing-plugin",
335+
icon: () => {},
336+
heading: "My amazing plugin",
337+
title: "my amazing plugin",
338+
panel: () => <p>My amazing content</p>,
339+
};
340+
341+
describe("when plugin has autoOpen true", () => {
342+
beforeEach(() => {
343+
const plugins = [
344+
{
345+
...defaultPlugin,
346+
autoOpen: true,
347+
},
348+
];
349+
render(
350+
<Provider store={store}>
351+
<div id="app">
352+
<Sidebar options={options} plugins={plugins} />
353+
</div>
354+
</Provider>,
355+
);
356+
});
357+
358+
test("Shows plugin icon", () => {
359+
expect(screen.queryByTitle("my amazing plugin")).toBeInTheDocument();
360+
});
361+
362+
test("Render the plugin panel open by default", () => {
363+
expect(screen.queryByText("My amazing plugin")).toBeInTheDocument();
364+
});
365+
366+
test("Renders the plugin content", () => {
367+
expect(screen.queryByText("My amazing content")).toBeInTheDocument();
368+
});
369+
});
370+
371+
describe("when plugin has autoOpen false", () => {
372+
beforeEach(() => {
373+
const plugins = [
374+
{
375+
...defaultPlugin,
376+
autoOpen: false,
377+
},
378+
];
379+
render(
380+
<Provider store={store}>
381+
<div id="app">
382+
<Sidebar options={options} plugins={plugins} />
383+
</div>
384+
</Provider>,
385+
);
386+
});
387+
388+
test("Shows plugin icon", () => {
389+
expect(screen.queryByTitle("my amazing plugin")).toBeInTheDocument();
390+
});
391+
392+
test("Does not render the plugin panel open by default", () => {
393+
expect(screen.queryByText("My amazing plugin")).not.toBeInTheDocument();
394+
});
395+
396+
test("Opening the panel shows the plugin heading", () => {
397+
const pluginButton = screen.getByTitle("my amazing plugin");
398+
fireEvent.click(pluginButton);
399+
expect(screen.queryByText("My amazing plugin")).toBeInTheDocument();
400+
});
401+
402+
test("Opening the panel shows the plugin content", () => {
403+
const pluginButton = screen.getByTitle("my amazing plugin");
404+
fireEvent.click(pluginButton);
405+
expect(screen.queryByText("My amazing content")).toBeInTheDocument();
406+
});
407+
});
408+
});

0 commit comments

Comments
 (0)