mirror of
https://gitlab.nic.cz/turris/reforis/foris-js.git
synced 2024-12-25 00:11:36 +01:00
Add tests for Switch
This commit is contained in:
parent
a0f7a312e5
commit
f64419c643
33
src/bootstrap/__tests__/Switch.test.js
Normal file
33
src/bootstrap/__tests__/Switch.test.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (C) 2020 CZ.NIC z.s.p.o. (http://www.nic.cz/)
|
||||
*
|
||||
* This is free software, licensed under the GNU General Public License v3.
|
||||
* See /LICENSE for more information.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
|
||||
import { render } from "customTestRender";
|
||||
|
||||
import { Switch } from "../Switch";
|
||||
|
||||
describe("<Switch/>", () => {
|
||||
it("Render switch", () => {
|
||||
const { container } = render(
|
||||
<Switch
|
||||
label="Test label"
|
||||
checked
|
||||
helpText="Some help text"
|
||||
onChange={() => {}}
|
||||
/>
|
||||
);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("Render uncheked switch", () => {
|
||||
const { container } = render(
|
||||
<Switch label="Test label" helpText="Some help text" />
|
||||
);
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
});
|
56
src/bootstrap/__tests__/__snapshots__/Switch.test.js.snap
Normal file
56
src/bootstrap/__tests__/__snapshots__/Switch.test.js.snap
Normal file
|
@ -0,0 +1,56 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Switch/> Render switch 1`] = `
|
||||
<div
|
||||
class="form-group"
|
||||
>
|
||||
<div
|
||||
class="custom-control custom-switch"
|
||||
>
|
||||
<input
|
||||
checked=""
|
||||
class="custom-control-input"
|
||||
id="1"
|
||||
type="checkbox"
|
||||
/>
|
||||
<label
|
||||
class="custom-control-label"
|
||||
for="1"
|
||||
>
|
||||
Test label
|
||||
</label>
|
||||
<small
|
||||
class="form-text text-muted mt-0 mb-3"
|
||||
>
|
||||
Some help text
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`<Switch/> Render uncheked switch 1`] = `
|
||||
<div
|
||||
class="form-group"
|
||||
>
|
||||
<div
|
||||
class="custom-control custom-switch"
|
||||
>
|
||||
<input
|
||||
class="custom-control-input"
|
||||
id="1"
|
||||
type="checkbox"
|
||||
/>
|
||||
<label
|
||||
class="custom-control-label"
|
||||
for="1"
|
||||
>
|
||||
Test label
|
||||
</label>
|
||||
<small
|
||||
class="form-text text-muted mt-0 mb-3"
|
||||
>
|
||||
Some help text
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
Loading…
Reference in New Issue
Block a user