1
0
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:
Aleksandr Gumroian 2020-08-18 17:37:08 +02:00
parent a0f7a312e5
commit f64419c643
No known key found for this signature in database
GPG Key ID: 9E77849C64F0A733
2 changed files with 89 additions and 0 deletions

View 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();
});
});

View 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>
`;