CEC-2545 Fix/can signals context (#210)

This commit is contained in:
arpanetus
2022-10-03 20:50:15 +06:00
committed by GitHub
parent d2a467d22b
commit 84fbf57daa
17 changed files with 347 additions and 205 deletions

View File

@@ -0,0 +1,39 @@
import addSnapshotSerializer from "../../../utils/snapshot";
jest.mock("../../Contexts/VehicleContext");
jest.mock("../../Contexts/StatusContext");
jest.mock("../../Contexts/UserContext");
jest.mock("@material-ui/core/utils/unstable_useId", () =>
jest.fn().mockReturnValue("mui-test-id")
);
import { render, waitFor } from "@testing-library/react";
import { BrowserRouter } from "react-router-dom";
import CANSignalsTab from "./CANSignalsTab";
import {setToken} from "../../Contexts/UserContext";
import {TEST_AUTH_OBJECT} from "../../../utils/testing";
const renderCANSignalsTab = async () => {
const { container } = render(
<BrowserRouter>
<CANSignalsTab vin="TESTVIN1234567890" token="token"/>
</BrowserRouter>
);
await waitFor(() => {
/* render */
});
return container;
};
describe("CANSignalsTab", () => {
beforeAll(() => {
addSnapshotSerializer(expect);
});
it("Render", async () => {
setToken(TEST_AUTH_OBJECT);
const container = await renderCANSignalsTab();
expect(container).toMatchSnapshot();
});
});

View File

@@ -0,0 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`CANSignalsTab Render 1`] = `
<div>
<div
data-testid="mocked-vehicleprovider"
>
<div
class="makeStyles-paper-0 makeStyles-tableSize-0"
>
<h6
class="MuiTypography-root MuiTypography-h6"
style="padding-bottom: 10px;"
>
CAN Signals
</h6>
<h3>
Loading...
</h3>
</div>
</div>
</div>
`;

View File

@@ -1,3 +1,150 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`DigitalTwinTab Render 1`] = `<div />`;
exports[`DigitalTwinTab Render 1`] = `
<div>
<div
data-testid="mocked-statusprovider"
>
<div
data-testid="mocked-userprovider"
>
<div
data-testid="mocked-vehicleprovider"
>
<div
class="makeStyles-paper-0 makeStyles-tableSize-0"
>
<h6
class="MuiTypography-root MuiTypography-h6"
style="padding-bottom: 10px;"
>
Digital Twin
</h6>
<div>
<b>
Connected
</b>
:
false
</div>
<div>
<b>
ICC Connected
</b>
:
true
</div>
<div>
<p>
<b>
Battery
</b>
:
95%
</p>
<div
class="makeStyles-popupSection-0"
>
<h3>
Doors
</h3>
<p>
<b>
hood
</b>
:
closed
</p>
<p>
<b>
left_front
</b>
:
closed
</p>
<p>
<b>
left_rear
</b>
:
closed
</p>
<p>
<b>
right_front
</b>
:
closed
</p>
<p>
<b>
right_rear
</b>
:
closed
</p>
<p>
<b>
trunk
</b>
:
closed
</p>
</div>
<div
class="makeStyles-popupSection-0"
>
<h3>
Location
</h3>
<p>
<b>
altitude
</b>
:
17
</p>
<p>
<b>
longitude
</b>
:
-122.414°
</p>
<p>
<b>
latitude
</b>
:
37.764°
</p>
</div>
<div
class="makeStyles-popupSection-0"
>
<p>
<b>
Trex Version
</b>
:
1000000
</p>
</div>
<div
class="makeStyles-popupSection-0"
>
<p>
<b>
Updated at
</b>
:
7/26/2022 12:26:38 AM
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;