Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Commit

Permalink
test: add dashboard component tests
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Murray <hellomikemurray@gmail.com>
  • Loading branch information
mikemurray committed Mar 30, 2020
1 parent 7c86cf3 commit 0676bcb
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
32 changes: 32 additions & 0 deletions package/src/Dashboard/Dashboard.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from "react";
import { render } from "../test-utils";
import Dashboard from "./Dashboard";

jest.mock("../hooks/useAuth", () => ({
__esModule: true,
default: () => ({
logout: jest.fn(),
viewer: {
primaryEmail: "test@reactioncommerce.com"
}
})
}));

const mockPlugins = [
{
route: "/test-1",
navTitle: "Test 1",
// eslint-disable-next-line react/display-name
MainComponent: () => (<span>Route Test 1</span>)
}
];

test("should be true", () => {
const { asFragment } = render((
<Dashboard
title="Test App"
plugins={mockPlugins}
/>
));
expect(asFragment()).toMatchSnapshot();
});
66 changes: 66 additions & 0 deletions package/src/Dashboard/__snapshots__/Dashboard.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`should be true 1`] = `
<DocumentFragment>
<div
class="MuiContainer-root MuiContainer-maxWidthLg"
>
<div
class="MuiDrawer-root MuiDrawer-docked"
>
<div
class="MuiPaper-root MuiDrawer-paper MuiDrawer-paperAnchorLeft MuiDrawer-paperAnchorDockedLeft MuiPaper-elevation0"
>
<ul
class="MuiList-root MuiList-padding"
>
<div
aria-disabled="false"
class="MuiButtonBase-root MuiListItem-root makeStyles-listItem-6 MuiListItem-gutters MuiListItem-button"
role="button"
tabindex="0"
>
<div
class="MuiListItemText-root makeStyles-listItemText-7"
>
Test 1
</div>
<span
class="MuiTouchRipple-root"
/>
</div>
<div
aria-disabled="false"
class="MuiButtonBase-root MuiListItem-root makeStyles-listItem-6 MuiListItem-gutters MuiListItem-button"
role="button"
tabindex="0"
>
<div
class="MuiListItemText-root makeStyles-listItemText-7"
>
Sign Out
</div>
<span
class="MuiTouchRipple-root"
/>
</div>
</ul>
</div>
</div>
<div
style="padding-left: 320px;"
>
<h1
class="MuiTypography-root MuiTypography-h1"
>
Test App
</h1>
<h2
class="MuiTypography-root MuiTypography-h2"
>
Welcome
</h2>
</div>
</div>
</DocumentFragment>
`;

0 comments on commit 0676bcb

Please sign in to comment.