1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2025-08-05 20:23:46 +02:00

Release 0.1.0

This commit is contained in:
Maciej Lenartowicz
2019-10-07 15:16:27 +00:00
parent 9e965bdcef
commit 50a1bfd9b5
38 changed files with 2651 additions and 518 deletions

View File

@@ -7,23 +7,39 @@
import React from "react";
import { render } from "customTestRender";
import { render, fireEvent, getByLabelText, wait } from "customTestRender";
import { NumberInput } from "../NumberInput";
describe("<NumberInput/>", () => {
it("Render number input", () => {
const onChangeMock = jest.fn();
let componentContainer;
beforeEach(() => {
const { container } = render(
<NumberInput
label="Test label"
helpText="Some help text"
value={1123}
onChange={() => {
}}
value={1}
onChange={onChangeMock}
/>
);
expect(container.firstChild)
.toMatchSnapshot();
componentContainer = container;
});
it("Render number input", () => {
expect(componentContainer.firstChild).toMatchSnapshot();
});
it("Increase number with button", async () => {
const increaseButton = getByLabelText(componentContainer, "Increase");
fireEvent.mouseDown(increaseButton);
await wait(() => expect(onChangeMock).toHaveBeenCalledWith({"target": {"value": 2}}));
});
it("Decrease number with button", async () => {
const decreaseButton = getByLabelText(componentContainer, "Decrease");
fireEvent.mouseDown(decreaseButton);
await wait(() => expect(onChangeMock).toHaveBeenCalledWith({"target": {"value": 0}}));
});
});