Skip to content

Commit

Permalink
Removed onReorder test as its changed to react sortable
Browse files Browse the repository at this point in the history
  • Loading branch information
vineethasok committed Oct 25, 2023
1 parent a64a1f4 commit 0cc0976
Showing 1 changed file with 1 addition and 43 deletions.
44 changes: 1 addition & 43 deletions src/components/FileTabs/FileTabs.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,50 +59,8 @@ describe("FileTabs", () => {

it("should call onSelect on clicking tab", () => {
const { getByTestId } = renderTabs({});
const tabElement = getByTestId("tab-element-tab1");
const tabElement = getByTestId("tab-element-0");
fireEvent.mouseDown(tabElement);
expect(onSelect).toBeCalledTimes(1);
});

it("should call onReorderTab on drag and drop", () => {
const { getByTestId } = renderTabs({});
const tabElement = getByTestId("tab-element-tab1");
expect(onReorderTab).toBeCalledTimes(0);
const mockDropEvent = createEvent.dragStart(tabElement);

const data: Record<string, string> = {};
Object.assign(mockDropEvent, {
dataTransfer: {
setData: (key: string, value: string) => (data[key] = value),
setDragImage: jest.fn(),
effectAllowed: "none",
getData: (key: string) => data[key],
},
});
fireEvent(tabElement, mockDropEvent);
fireEvent.dragOver(getByTestId("tab-element-tab2"));
fireEvent.drop(getByTestId("tab-container"));
expect(onReorderTab).toBeCalledTimes(1);
});

it("should not call onReorderTab on drag and drop outside the container", () => {
const { getByTestId } = renderTabs({});
const tabElement = getByTestId("tab-element-tab1");
expect(onReorderTab).toBeCalledTimes(0);
const mockDropEvent = createEvent.dragStart(tabElement);

const data: Record<string, string> = {};
Object.assign(mockDropEvent, {
dataTransfer: {
setData: (key: string, value: string) => (data[key] = value),
setDragImage: jest.fn(),
effectAllowed: "none",
getData: (key: string) => data[key],
},
});
fireEvent(tabElement, mockDropEvent);
fireEvent.dragOver(getByTestId("tab-element-tab2"));
fireEvent.drop(document.body);
expect(onReorderTab).toBeCalledTimes(0);
});
});

0 comments on commit 0cc0976

Please sign in to comment.