2020-02-12 02:19:43 +04:00
|
|
|
import { queries, buildQueries } from "@testing-library/react";
|
|
|
|
|
|
|
|
const _getAllByToolName = (container: HTMLElement, tool: string) => {
|
|
|
|
const toolMap: { [propKey: string]: string } = {
|
|
|
|
selection: "Selection — S, 1",
|
|
|
|
rectangle: "Rectangle — R, 2",
|
|
|
|
diamond: "Diamond — D, 3",
|
|
|
|
ellipse: "Ellipse — E, 4",
|
|
|
|
arrow: "Arrow — A, 5",
|
|
|
|
line: "Line — L, 6",
|
|
|
|
};
|
|
|
|
|
|
|
|
const toolTitle = toolMap[tool as string];
|
|
|
|
return queries.getAllByTitle(container, toolTitle);
|
|
|
|
};
|
|
|
|
|
2020-03-07 10:20:38 -05:00
|
|
|
const getMultipleError = (_container: any, tool: any) =>
|
2020-02-12 02:19:43 +04:00
|
|
|
`Found multiple elements with tool name: ${tool}`;
|
2020-03-07 10:20:38 -05:00
|
|
|
const getMissingError = (_container: any, tool: any) =>
|
2020-02-12 02:19:43 +04:00
|
|
|
`Unable to find an element with tool name: ${tool}`;
|
|
|
|
|
|
|
|
export const [
|
|
|
|
queryByToolName,
|
|
|
|
getAllByToolName,
|
|
|
|
getByToolName,
|
|
|
|
findAllByToolName,
|
|
|
|
findByToolName,
|
|
|
|
] = buildQueries<string[]>(
|
|
|
|
_getAllByToolName,
|
|
|
|
getMultipleError,
|
|
|
|
getMissingError,
|
|
|
|
);
|