Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 51 additions & 42 deletions src/components/SecondaryPanes/Frames/tests/Frames.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,50 @@ function render(overrides = {}) {
}

describe("Frames", () => {
it("empty frames", () => {
const component = render();
expect(component).toMatchSnapshot();
});
describe("Supports different number of frames", () => {
it("empty frames", () => {
const component = render();
expect(component).toMatchSnapshot();
expect(component.find(".show-more").exists()).toBeFalsy();
});

it("one frame", () => {
const frames = [{ id: 1 }];
const selectedFrame = frames[0];
const component = render({ frames, selectedFrame });

it("one frame", () => {
const frames = [{ id: 1 }];
const selectedFrame = frames[0];
const component = render({ frames, selectedFrame });
expect(component.find(".show-more").exists()).toBeFalsy();
expect(component).toMatchSnapshot();
});

expect(component).toMatchSnapshot();
});
it("toggling the show more button", () => {
const frames = [
{ id: 1 },
{ id: 2 },
{ id: 3 },
{ id: 4 },
{ id: 5 },
{ id: 6 },
{ id: 7 },
{ id: 8 },
{ id: 9 },
{ id: 10 }
];

const selectedFrame = frames[0];
const component = render({ selectedFrame, frames });

const getToggleBtn = () => component.find(".show-more");
const getFrames = () => component.find("FrameComponent");

it("lots of frames", () => {
const frames = [
{ id: 1 },
{ id: 2 },
{ id: 3 },
{ id: 4 },
{ id: 5 },
{ id: 6 },
{ id: 7 },
{ id: 8 }
];
const selectedFrame = frames[0];
const component = render({ frames, selectedFrame });

expect(component).toMatchSnapshot();
const showMore = component.node.props.children[2];
expect(showMore.props.className).toEqual("show-more");
expect(getToggleBtn().text()).toEqual("Expand Rows");
expect(getFrames().length).toEqual(7);

getToggleBtn().simulate("click");
expect(getToggleBtn().text()).toEqual("Collapse Rows");
expect(getFrames().length).toEqual(10);
expect(component).toMatchSnapshot();
});
});

describe("Blackboxed Frames", () => {
Expand All @@ -70,42 +84,37 @@ describe("Frames", () => {

const processedFrames = getAndProcessFrames(frames, sources);
const selectedFrame = frames[0];

const component = render({
frames: processedFrames,
frameworkGroupingOn: false,
selectedFrame
});

expect(component.find("FrameComponent").length).toEqual(2);
expect(component).toMatchSnapshot();
});
});

describe("Library Frames", () => {
it("expand framework frames into a multiple frames", () => {
it("toggling framework frames", () => {
const frames = [
{ id: 1 },
{ id: 2, library: "back" },
{ id: 3, library: "back" },
{ id: 8 }
];

const selectedFrame = frames[0];
const frameworkGroupingOn = false;
const component = render({ frames, frameworkGroupingOn, selectedFrame });

expect(component.find("FrameComponent").length).toEqual(4);
expect(component).toMatchSnapshot();
});

it("collapse framework frames into a single frame", () => {
const frames = [
{ id: 1 },
{ id: 2, library: "back" },
{ id: 3, library: "back" },
{ id: 8 }
];
const selectedFrame = frames[0];
const component = render({
frames,
selectedFrame,
frameworkGroupingOn: true
});
component.setProps({ frameworkGroupingOn: true });

expect(component.find("FrameComponent").length).toEqual(2);
expect(component).toMatchSnapshot();
});
});
Expand Down
Loading