1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-07 21:23:00 +03:00

Apply prettier formatting

This commit is contained in:
Michael Weimann
2022-12-12 12:24:14 +01:00
parent 1cac306093
commit 526645c791
1576 changed files with 65385 additions and 62478 deletions

View File

@@ -14,64 +14,64 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import React from 'react';
import React from "react";
import { render, screen, fireEvent } from "@testing-library/react";
import { mocked } from 'jest-mock';
import { MatrixClient } from 'matrix-js-sdk/src/matrix';
import { mocked } from "jest-mock";
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import SpacePanel from '../../../../src/components/views/spaces/SpacePanel';
import { MatrixClientPeg } from '../../../../src/MatrixClientPeg';
import { SpaceKey } from '../../../../src/stores/spaces';
import { shouldShowComponent } from '../../../../src/customisations/helpers/UIComponents';
import { UIComponent } from '../../../../src/settings/UIFeature';
import SpacePanel from "../../../../src/components/views/spaces/SpacePanel";
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
import { SpaceKey } from "../../../../src/stores/spaces";
import { shouldShowComponent } from "../../../../src/customisations/helpers/UIComponents";
import { UIComponent } from "../../../../src/settings/UIFeature";
jest.mock('../../../../src/stores/spaces/SpaceStore', () => {
jest.mock("../../../../src/stores/spaces/SpaceStore", () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const EventEmitter = require("events");
class MockSpaceStore extends EventEmitter {
invitedSpaces = [];
enabledMetaSpaces = [];
spacePanelSpaces = [];
activeSpace: SpaceKey = '!space1';
activeSpace: SpaceKey = "!space1";
}
return {
instance: new MockSpaceStore(),
};
});
jest.mock('../../../../src/customisations/helpers/UIComponents', () => ({
jest.mock("../../../../src/customisations/helpers/UIComponents", () => ({
shouldShowComponent: jest.fn(),
}));
describe('<SpacePanel />', () => {
describe("<SpacePanel />", () => {
const mockClient = {
getUserId: jest.fn().mockReturnValue('@test:test'),
getUserId: jest.fn().mockReturnValue("@test:test"),
isGuest: jest.fn(),
getAccountData: jest.fn(),
} as unknown as MatrixClient;
beforeAll(() => {
jest.spyOn(MatrixClientPeg, 'get').mockReturnValue(mockClient);
jest.spyOn(MatrixClientPeg, "get").mockReturnValue(mockClient);
});
beforeEach(() => {
mocked(shouldShowComponent).mockClear().mockReturnValue(true);
});
describe('create new space button', () => {
it('renders create space button when UIComponent.CreateSpaces component should be shown', () => {
describe("create new space button", () => {
it("renders create space button when UIComponent.CreateSpaces component should be shown", () => {
render(<SpacePanel />);
screen.getByTestId("create-space-button");
});
it('does not render create space button when UIComponent.CreateSpaces component should not be shown', () => {
it("does not render create space button when UIComponent.CreateSpaces component should not be shown", () => {
mocked(shouldShowComponent).mockReturnValue(false);
render(<SpacePanel />);
expect(shouldShowComponent).toHaveBeenCalledWith(UIComponent.CreateSpaces);
expect(screen.queryByTestId("create-space-button")).toBeFalsy();
});
it('opens context menu on create space button click', () => {
it("opens context menu on create space button click", () => {
render(<SpacePanel />);
fireEvent.click(screen.getByTestId("create-space-button"));
screen.getByTestId("create-space-button");