fix(ui): add tests for CenteredMessage

This commit is contained in:
Łukasz Mierzwa
2019-12-12 22:34:41 +00:00
parent ccc44b042a
commit ec3fdd47ec
2 changed files with 52 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<CenteredMessage /> matches snapshot 1`] = `
"
<h1 class=\\"display-1 text-placeholder screen-center\\">
<div>
Foo
</div>
</h1>
"
`;

View File

@@ -0,0 +1,41 @@
import React from "react";
import { shallow } from "enzyme";
import toDiffableHtml from "diffable-html";
import { CenteredMessage } from ".";
describe("<CenteredMessage />", () => {
const Message = () => <div>Foo</div>;
it("matches snapshot", () => {
const tree = shallow(
<CenteredMessage>
<Message />
</CenteredMessage>
);
expect(toDiffableHtml(tree.html())).toMatchSnapshot();
});
it("uses 'display-1 text-placeholder' className by default", () => {
const tree = shallow(
<CenteredMessage>
<Message />
</CenteredMessage>
);
expect(toDiffableHtml(tree.html())).toMatch(/display-1 text-placeholder/);
});
it("uses custom className if passed", () => {
const tree = shallow(
<CenteredMessage className="bar-class">
<Message />
</CenteredMessage>
);
expect(toDiffableHtml(tree.html())).toMatch(/bar-class/);
expect(toDiffableHtml(tree.html())).not.toMatch(
/display-1 text-placeholder/
);
});
});