Skip to content

Commit a994697

Browse files
Merge pull request #452 from primeroIMS/trigyn-testcases-mobile-toolbar
Trigyn testcases mobile toolbar
2 parents c940c3b + 41570c2 commit a994697

File tree

6 files changed

+52
-60
lines changed

6 files changed

+52
-60
lines changed

app/javascript/components/mobile-toolbar/component.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ const MobileToolbar = ({ openDrawer, hasUnsubmittedOfflineChanges = false }) =>
2222

2323
return (
2424
<Hidden mdUp implementation="css">
25-
<AppBar position="fixed">
26-
<Toolbar className={css[demo ? "toolbar-demo" : "toolbar"]}>
25+
<AppBar position="fixed" data-testid="appBar">
26+
<Toolbar data-testid="toolbar" className={css[demo ? "toolbar-demo" : "toolbar"]}>
2727
<IconButton edge="start" color="default" aria-label="Menu" onClick={openDrawer}>
2828
<MenuIcon className={css.hamburger} />
2929
{hasUnsubmittedOfflineChanges && (
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { fromJS } from "immutable";
2+
3+
import { mountedComponent, screen, setScreenSizeToMobile } from "../../test-utils";
4+
5+
import MobileToolbar from "./component";
6+
7+
describe("<MobileToolbar />", () => {
8+
const state = fromJS({ MobileToolbar: { module: "primero" } });
9+
const props = { openDrawer: () => {} };
10+
11+
beforeAll(() => {
12+
setScreenSizeToMobile(false);
13+
});
14+
15+
it("should render MobileToolbar component", () => {
16+
mountedComponent(<MobileToolbar {...props} />, state);
17+
expect(screen.getByTestId("appBar")).toBeInTheDocument();
18+
});
19+
20+
it("should render Logo component", () => {
21+
mountedComponent(<MobileToolbar {...props} />, state);
22+
expect(screen.getByTestId("logo-primero")).toBeInTheDocument();
23+
});
24+
25+
describe("when is not demo site", () => {
26+
it("should not render a <div> tag with 'Demo' text", () => {
27+
mountedComponent(<MobileToolbar {...props} />, state);
28+
expect(screen.getByText(/sandbox_ui/i)).not.toBeInTheDocument();
29+
});
30+
});
31+
32+
describe("when is demo site", () => {
33+
const stateWithDemo = fromJS({
34+
application: {
35+
primero: {
36+
sandbox_ui: true
37+
}
38+
}
39+
});
40+
41+
it("should render a <div> tag with 'Demo' text", () => {
42+
mountedComponent(<MobileToolbar {...props} />, stateWithDemo);
43+
expect(screen.getByText(/sandbox_ui/i)).toBeInTheDocument();
44+
});
45+
});
46+
});

app/javascript/components/mobile-toolbar/component.unit.test.js

-57
This file was deleted.

app/javascript/components/pdf-exporter/component.spec.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
import { createRef } from "react";
44
import { fromJS } from "immutable";
55

6+
import { screen, mountedFormComponent } from "../../test-utils";
7+
68
import PdfExporter from "./component";
7-
import { mountedFormComponent, screen } from "../../test-utils";
89

910
describe("<PdfExporter />", () => {
1011
const formRef = createRef();

app/javascript/components/pdf-exporter/components/key-value-cell/component.spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { mountedComponent, screen } from "../../../../test-utils";
2+
23
import KeyValueCell from "./component";
34

45
describe("components/record-actions/exports/components/pdf-exporter/components/key-value-cell", () => {

app/javascript/components/pdf-exporter/components/logos/component.spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { mountedComponent, screen } from "../../../../test-utils";
2+
23
import Logos from "./component";
34

45
describe("<Logos />", () => {

0 commit comments

Comments
 (0)