1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2025-06-16 13:46:16 +02:00

Disable default styles for number input

This commit is contained in:
Maciej Lenartowicz
2019-09-25 11:59:45 +00:00
parent 7371fbcac0
commit 7253319b61
6 changed files with 105 additions and 13 deletions

View File

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

View File

@ -19,8 +19,30 @@ exports[`<NumberInput/> Render number input 1`] = `
class="form-control"
id="1"
type="number"
value="1123"
value="1"
/>
<div
class="input-group-append"
>
<button
aria-label="Increase"
class="btn btn-outline-secondary"
type="button"
>
<i
class="fas fa-plus"
/>
</button>
<button
aria-label="Decrease"
class="btn btn-outline-secondary"
type="button"
>
<i
class="fas fa-minus"
/>
</button>
</div>
</div>
<small
class="form-text text-muted"