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