2022-03-11 16:52:57 +08:00
|
|
|
/*
|
2024-09-09 21:57:16 +08:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2022-03-11 16:52:57 +08:00
|
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
|
2024-09-09 21:57:16 +08:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2022-03-11 16:52:57 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
import React from "react";
|
2024-10-15 00:11:58 +08:00
|
|
|
import { render, RenderResult } from "jest-matrix-react";
|
2022-03-11 16:52:57 +08:00
|
|
|
|
2024-10-15 21:57:26 +08:00
|
|
|
import { MapError, MapErrorProps } from "../../../../../src/components/views/location/MapError";
|
|
|
|
import { LocationShareError } from "../../../../../src/utils/location";
|
2022-03-11 16:52:57 +08:00
|
|
|
|
|
|
|
describe("<MapError />", () => {
|
|
|
|
const defaultProps = {
|
|
|
|
onFinished: jest.fn(),
|
|
|
|
error: LocationShareError.MapStyleUrlNotConfigured,
|
2022-07-06 22:34:33 +08:00
|
|
|
className: "test",
|
2022-03-11 16:52:57 +08:00
|
|
|
};
|
2022-07-06 22:34:33 +08:00
|
|
|
const getComponent = (props: Partial<MapErrorProps> = {}): RenderResult =>
|
|
|
|
render(<MapError {...defaultProps} {...props} />);
|
2022-03-11 16:52:57 +08:00
|
|
|
|
|
|
|
it("renders correctly for MapStyleUrlNotConfigured", () => {
|
2022-07-06 22:34:33 +08:00
|
|
|
const { container } = getComponent();
|
|
|
|
expect(container).toMatchSnapshot();
|
2022-03-11 16:52:57 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it("renders correctly for MapStyleUrlNotReachable", () => {
|
2022-07-06 22:34:33 +08:00
|
|
|
const { container } = getComponent({
|
2022-03-11 16:52:57 +08:00
|
|
|
error: LocationShareError.MapStyleUrlNotReachable,
|
|
|
|
});
|
2022-07-06 22:34:33 +08:00
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("does not render button when onFinished falsy", () => {
|
|
|
|
const { queryByText } = getComponent({
|
|
|
|
error: LocationShareError.MapStyleUrlNotReachable,
|
|
|
|
onFinished: undefined,
|
|
|
|
});
|
|
|
|
// no button
|
|
|
|
expect(queryByText("OK")).toBeFalsy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("applies class when isMinimised is truthy", () => {
|
|
|
|
const { container } = getComponent({
|
|
|
|
isMinimised: true,
|
|
|
|
});
|
|
|
|
expect(container).toMatchSnapshot();
|
2022-03-11 16:52:57 +08:00
|
|
|
});
|
|
|
|
});
|