2022-03-11 11:52:57 +03:00
|
|
|
/*
|
2024-09-09 16:57:16 +03:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2022-03-11 11:52:57 +03:00
|
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
|
2024-09-09 16:57:16 +03: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 11:52:57 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
import React from "react";
|
2022-07-06 17:34:33 +03:00
|
|
|
import { render, RenderResult } from "@testing-library/react";
|
2022-03-11 11:52:57 +03:00
|
|
|
|
2022-07-06 17:34:33 +03:00
|
|
|
import { MapError, MapErrorProps } from "../../../../src/components/views/location/MapError";
|
2022-03-25 17:36:22 +03:00
|
|
|
import { LocationShareError } from "../../../../src/utils/location";
|
2022-03-11 11:52:57 +03:00
|
|
|
|
|
|
|
describe("<MapError />", () => {
|
|
|
|
const defaultProps = {
|
|
|
|
onFinished: jest.fn(),
|
|
|
|
error: LocationShareError.MapStyleUrlNotConfigured,
|
2022-07-06 17:34:33 +03:00
|
|
|
className: "test",
|
2022-03-11 11:52:57 +03:00
|
|
|
};
|
2022-07-06 17:34:33 +03:00
|
|
|
const getComponent = (props: Partial<MapErrorProps> = {}): RenderResult =>
|
|
|
|
render(<MapError {...defaultProps} {...props} />);
|
2022-03-11 11:52:57 +03:00
|
|
|
|
|
|
|
it("renders correctly for MapStyleUrlNotConfigured", () => {
|
2022-07-06 17:34:33 +03:00
|
|
|
const { container } = getComponent();
|
|
|
|
expect(container).toMatchSnapshot();
|
2022-03-11 11:52:57 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it("renders correctly for MapStyleUrlNotReachable", () => {
|
2022-07-06 17:34:33 +03:00
|
|
|
const { container } = getComponent({
|
2022-03-11 11:52:57 +03:00
|
|
|
error: LocationShareError.MapStyleUrlNotReachable,
|
|
|
|
});
|
2022-07-06 17:34:33 +03: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 11:52:57 +03:00
|
|
|
});
|
|
|
|
});
|