From 4aec8404a9a20b25b4e40f5a14923b222b60da88 Mon Sep 17 00:00:00 2001 From: Estelle Comment Date: Mon, 7 Nov 2022 16:52:54 +0100 Subject: [PATCH 1/7] Fix linter --- res/themes/tchap-light/css/_tchap_custom_vars.pcss | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/res/themes/tchap-light/css/_tchap_custom_vars.pcss b/res/themes/tchap-light/css/_tchap_custom_vars.pcss index 069997aefb..047bf489bb 100644 --- a/res/themes/tchap-light/css/_tchap_custom_vars.pcss +++ b/res/themes/tchap-light/css/_tchap_custom_vars.pcss @@ -29,7 +29,12 @@ body { --username-colors_5: #000091; --username-colors_6: #000091; --username-colors_7: #000091; - --avatar-background-colors_0:#8F96A4; /* if using getComputedStyle(document.body).getPropertyValue it's better to leave no space */ + + /* if using getComputedStyle(document.body).getPropertyValue it's better to leave no space */ + /* stylelint-disable-next-line declaration-colon-space-after */ + --avatar-background-colors_0:#8F96A4; + /* stylelint-disable-next-line declaration-colon-space-after */ --avatar-background-colors_1:#8F96A4; + /* stylelint-disable-next-line declaration-colon-space-after */ --avatar-background-colors_2:#8F96A4; } From 46c12c54ddd05733860042746846eb642ca3f51f Mon Sep 17 00:00:00 2001 From: Estelle Comment Date: Mon, 7 Nov 2022 17:07:29 +0100 Subject: [PATCH 2/7] Lint file --- .../dialogs/TchapCreateRoomDialog-test.tsx | 96 +++++++++---------- 1 file changed, 46 insertions(+), 50 deletions(-) diff --git a/test/unit-tests/components/views/dialogs/TchapCreateRoomDialog-test.tsx b/test/unit-tests/components/views/dialogs/TchapCreateRoomDialog-test.tsx index 43bb570153..05b2bad3ff 100644 --- a/test/unit-tests/components/views/dialogs/TchapCreateRoomDialog-test.tsx +++ b/test/unit-tests/components/views/dialogs/TchapCreateRoomDialog-test.tsx @@ -1,17 +1,15 @@ import React from 'react'; -import { mount, ReactWrapper,shallow } from 'enzyme'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { mount, ReactWrapper } from 'enzyme'; import { act } from 'react-dom/test-utils'; -import toJson from 'enzyme-to-json' - -//jest.mock('matrix-react-sdk/src/languageHandler') - -import { TchapRoomType } from '../../../../../src/@types/tchap'; +import toJson from 'enzyme-to-json'; import { MatrixClientPeg } from 'matrix-react-sdk/src/MatrixClientPeg'; import { EventEmitter } from "events"; -import { _t } from 'matrix-react-sdk/src/languageHandler'; +import { TchapRoomType } from '../../../../../src/@types/tchap'; import TchapUtils from '../../../../../src/util/TchapUtils'; +import TchapCreateRoomDialog from "../../../../../src/components/views/dialogs/TchapCreateRoomDialog"; //mocking module with jest.mock should be done outside the test. Before any import of the mocked module. //I could not make a mock of TchapCreateRoomDialog, the real implementation was taken each time. Then I used jest spyOn @@ -25,8 +23,6 @@ import TchapUtils from '../../../../../src/util/TchapUtils'; }); */ -import TchapCreateRoomDialog from "../../../../../src/components/views/dialogs/TchapCreateRoomDialog"; - /* * This unit test targets the TchapCreateRoomDialog react component. It is mounted virtually to be tested thanks to enzyme framework. * With the act function, a state is set inside the component, meanwhile the submitForm function submits the form in order to make action on the internal state of the component. @@ -42,20 +38,20 @@ describe("TchapCreateRoomDialog", () => { defaultName: undefined, // unused for Tchap version parentSpace: undefined, // unused for Tchap version defaultEncrypted: undefined, // unused for Tchap version - onFinished: jest.fn() + onFinished: jest.fn(), }; //simulate the submit of the form - const submitForm = async (wrapper: ReactWrapper) =>{ + const submitForm = async (wrapper: ReactWrapper) => { act(() => { wrapper.find('form').simulate('submit', { preventDefault: () => { } }); - }) + }); await new Promise(process.nextTick); - } + }; // build a new component using enzyme const getComponent = (props = {}): ReactWrapper => - mount(); + mount(); /* // Note : you can also build a shallow component https://fr.reactjs.org/docs/shallow-renderer.html @@ -75,7 +71,8 @@ describe("TchapCreateRoomDialog", () => { //mock tchap utils jest.spyOn(TchapUtils, 'getShortDomain').mockReturnValue("AGENT"); - jest.spyOn(TchapUtils, 'getRoomFederationOptions').mockReturnValue({ showRoomFederationOption: true, roomFederationDefault: false }); + jest.spyOn(TchapUtils, 'getRoomFederationOptions').mockReturnValue( + { showRoomFederationOption: true, roomFederationDefault: false }); }); it('should render the whole component', () => { @@ -85,14 +82,17 @@ describe("TchapCreateRoomDialog", () => { }); it('should render the whole component with with the allow access switch', () => { - jest.spyOn(TchapUtils, 'getRoomFederationOptions').mockReturnValue({ showRoomFederationOption: true, roomFederationDefault: false }); + jest.spyOn(TchapUtils, 'getRoomFederationOptions').mockReturnValue( + { showRoomFederationOption: true, roomFederationDefault: false }); const component = getComponent(); const allowAccessSwitch = component.find(".mx_SettingsFlag"); - expect(toJson(allowAccessSwitch)).toMatchSnapshot("allow access switch is present, allows other domain than AGENT"); + expect(toJson(allowAccessSwitch)).toMatchSnapshot( + "allow access switch is present, allows other domain than AGENT"); }); it('should render the room dialog without the allow access switch', () => { - jest.spyOn(TchapUtils, 'getRoomFederationOptions').mockReturnValue({ showRoomFederationOption: false, roomFederationDefault: false }); + jest.spyOn(TchapUtils, 'getRoomFederationOptions').mockReturnValue( + { showRoomFederationOption: false, roomFederationDefault: false }); const component = getComponent(); const allowAccessSwitch = component.find(".mx_SettingsFlag"); expect(allowAccessSwitch).toEqual({}); @@ -100,35 +100,35 @@ describe("TchapCreateRoomDialog", () => { it("Should not create any room wihout a name", async () => { const onFinished = jest.fn(); - const wrapper = getComponent({ onFinished}); + const wrapper = getComponent({ onFinished }); // set state in component act(() => { wrapper.setState({ name: "", - tchapRoomType: TchapRoomType.Private + tchapRoomType: TchapRoomType.Private, }); }); await submitForm(wrapper); expect(onFinished).toBeCalledTimes(0); - }) + }); it("Should create a room with default value", async () => { const onFinished = jest.fn(); const defaultName = "defaultName"; - const wrapper = getComponent({ onFinished, defaultName}); - // set state in component + const wrapper = getComponent({ onFinished, defaultName }); + // set state in component act(() => { wrapper.setState({ - tchapRoomType: TchapRoomType.Private + tchapRoomType: TchapRoomType.Private, }); }); await submitForm(wrapper); expect(onFinished).toBeCalledTimes(1); - }) + }); it("Should create a private room", async () => { const onFinished = jest.fn(); @@ -139,10 +139,10 @@ describe("TchapCreateRoomDialog", () => { creation_content: { "m.federate": true, }, - "initial_state": [ + initial_state: [ { "content": { - "rule": "restricted", + "rule": "restricted", }, "state_key": "", "type": "im.vector.room.access_rules", @@ -157,22 +157,21 @@ describe("TchapCreateRoomDialog", () => { historyVisibility: "invited", }; - const wrapper = getComponent({ onFinished}); + const wrapper = getComponent({ onFinished }); // set state in component act(() => { wrapper.setState({ name: roomName, tchapRoomType: TchapRoomType.Private, - isFederated:true + isFederated: true, }); }); await submitForm(wrapper); expect(onFinished).toHaveBeenCalledWith(true, privateRoomExpectedOpts); - }) - + }); it("Should create a public room without federation", async () => { const onFinished = jest.fn(); @@ -183,10 +182,10 @@ describe("TchapCreateRoomDialog", () => { creation_content: { "m.federate": false, }, - "initial_state": [ + initial_state: [ { "content": { - "rule": "restricted", + "rule": "restricted", }, "state_key": "", "type": "im.vector.room.access_rules", @@ -200,21 +199,21 @@ describe("TchapCreateRoomDialog", () => { encryption: false, historyVisibility: "shared", }; - const wrapper = getComponent({ onFinished}); + const wrapper = getComponent({ onFinished }); // set state in component act(() => { wrapper.setState({ name: roomName, tchapRoomType: TchapRoomType.Forum, - isFederated:false + isFederated: false, }); }); await submitForm(wrapper); expect(onFinished).toHaveBeenCalledWith(true, publicRoomWithoutFederationExpectedOpts); - }) + }); it("Should create a public room with federation", async () => { const onFinished = jest.fn(); @@ -225,10 +224,10 @@ describe("TchapCreateRoomDialog", () => { creation_content: { "m.federate": true, }, - "initial_state": [ + initial_state: [ { "content": { - "rule": "restricted", + "rule": "restricted", }, "state_key": "", "type": "im.vector.room.access_rules", @@ -242,21 +241,21 @@ describe("TchapCreateRoomDialog", () => { encryption: false, historyVisibility: "shared", }; - const wrapper = getComponent({ onFinished}); + const wrapper = getComponent({ onFinished }); // set state in component act(() => { wrapper.setState({ name: roomName, tchapRoomType: TchapRoomType.Forum, - isFederated:true + isFederated: true, }); }); await submitForm(wrapper); expect(onFinished).toHaveBeenCalledWith(true, publicRoomWithFederationExpectedOpts); - }) + }); it("Should create an external room", async () => { const onFinished = jest.fn(); @@ -267,10 +266,10 @@ describe("TchapCreateRoomDialog", () => { creation_content: { "m.federate": true, }, - "initial_state": [ + initial_state: [ { "content": { - "rule": "unrestricted", + "rule": "unrestricted", }, "state_key": "", "type": "im.vector.room.access_rules", @@ -284,23 +283,22 @@ describe("TchapCreateRoomDialog", () => { encryption: true, historyVisibility: "invited", }; - const wrapper = getComponent({ onFinished}); + const wrapper = getComponent({ onFinished }); // set state in component act(() => { wrapper.setState({ name: roomName, tchapRoomType: TchapRoomType.External, - isFederated:true + isFederated: true, }); }); await submitForm(wrapper); expect(onFinished).toHaveBeenCalledWith(true, externalRoomExpectedOpts); - }) -}) - + }); +}); class MockClient extends EventEmitter { // getUserId = jest.fn(); @@ -321,5 +319,3 @@ class MockClient extends EventEmitter { // getClientWellKnown = jest.fn(); getDomain = jest.fn(); } - - From 5ef73f80bfa363660655393521ed46f8eb49d300 Mon Sep 17 00:00:00 2001 From: Estelle Comment Date: Mon, 7 Nov 2022 17:53:12 +0100 Subject: [PATCH 3/7] Lint test files --- .eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.js b/.eslintrc.js index 1ba5349f05..29fdb716d3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -23,6 +23,7 @@ module.exports = { "module_system/**/*.{ts,tsx}", // :TCHAP: Lint our cypress files, copied from react-sdk. React-sdk lints them too, so we keep up ! "cypress/**/*.ts", + "test/**/*.{ts,tsx,js}", ], extends: [ "plugin:matrix-org/typescript", From f080db3eab5c3afd12dbab9221a71e3f88f27593 Mon Sep 17 00:00:00 2001 From: Estelle Comment Date: Mon, 7 Nov 2022 17:53:25 +0100 Subject: [PATCH 4/7] fix linter --- test/setupTests.js | 3 +- .../dialogs/TchapCreateRoomDialog-test.tsx | 2 +- .../settings/TchapJoinRuleSettings-test.tsx | 78 ++++++++++--------- 3 files changed, 43 insertions(+), 40 deletions(-) diff --git a/test/setupTests.js b/test/setupTests.js index e4bd838d37..6b1f25aef2 100644 --- a/test/setupTests.js +++ b/test/setupTests.js @@ -1,5 +1,6 @@ //is duplicated from matrix-react-sdk/test/setupTests.js in order to work import Adapter from "@wojtekmaj/enzyme-adapter-react-17"; +// eslint-disable-next-line deprecate/import import { configure } from "enzyme"; -configure({ adapter: new Adapter() }); \ No newline at end of file +configure({ adapter: new Adapter() }); diff --git a/test/unit-tests/components/views/dialogs/TchapCreateRoomDialog-test.tsx b/test/unit-tests/components/views/dialogs/TchapCreateRoomDialog-test.tsx index 05b2bad3ff..0731185a0d 100644 --- a/test/unit-tests/components/views/dialogs/TchapCreateRoomDialog-test.tsx +++ b/test/unit-tests/components/views/dialogs/TchapCreateRoomDialog-test.tsx @@ -1,6 +1,6 @@ import React from 'react'; -// eslint-disable-next-line @typescript-eslint/no-unused-vars +// eslint-disable-next-line @typescript-eslint/no-unused-vars deprecate/import import { mount, ReactWrapper } from 'enzyme'; import { act } from 'react-dom/test-utils'; import toJson from 'enzyme-to-json'; diff --git a/test/unit-tests/components/views/settings/TchapJoinRuleSettings-test.tsx b/test/unit-tests/components/views/settings/TchapJoinRuleSettings-test.tsx index 6220f244bc..7014e361cc 100644 --- a/test/unit-tests/components/views/settings/TchapJoinRuleSettings-test.tsx +++ b/test/unit-tests/components/views/settings/TchapJoinRuleSettings-test.tsx @@ -1,17 +1,16 @@ import React from "react"; import { render, screen } from "@testing-library/react"; import { mocked } from 'jest-mock'; - -import TchapJoinRuleSettings from "../../../../../src/components/views/settings/TchapJoinRuleSettings"; -import { createTestClient, mkStubRoom, mockStateEventImplementation, mkEvent } from "matrix-react-sdk/test/test-utils/test-utils"; +import { createTestClient, mkStubRoom, mockStateEventImplementation, mkEvent } + from "matrix-react-sdk/test/test-utils/test-utils"; import { JoinRule, MatrixClient, Room } from "matrix-js-sdk/src/matrix"; -import { TchapRoomAccessRule, TchapRoomAccessRulesEventId } from "../../../../../src/@types/tchap"; - +import TchapJoinRuleSettings from "../../../../../src/components/views/settings/TchapJoinRuleSettings"; +import { TchapRoomAccessRule, TchapRoomAccessRulesEventId } from "../../../../../src/@types/tchap"; function mkStubRoomWithInviteRule(roomId: string, name: string, client: MatrixClient, joinRule: JoinRule): Room { - const stubRoom:Room = mkStubRoom(roomId,name,client); - stubRoom.getJoinRule = jest.fn().mockReturnValue(joinRule); + const stubRoom: Room = mkStubRoom(roomId,name,client); + stubRoom.getJoinRule = jest.fn().mockReturnValue(joinRule); stubRoom.currentState.getJoinRule = jest.fn().mockReturnValue(joinRule); return stubRoom; } @@ -22,9 +21,14 @@ const makeAccessEvent = (rule: TchapRoomAccessRule = TchapRoomAccessRule.Restric }, } as any); -function mkStubRoomWithAccessRule(roomId: string, name: string, client: MatrixClient, joinRule: JoinRule, accessRule: TchapRoomAccessRule): Room { - const stubRoom:Room = mkStubRoom(roomId,name,client); - stubRoom.getJoinRule = jest.fn().mockReturnValue(joinRule); +function mkStubRoomWithAccessRule( + roomId: string, + name: string, + client: MatrixClient, + joinRule: JoinRule, + accessRule: TchapRoomAccessRule): Room { + const stubRoom: Room = mkStubRoom(roomId, name, client); + stubRoom.getJoinRule = jest.fn().mockReturnValue(joinRule); stubRoom.currentState.getJoinRule = jest.fn().mockReturnValue(joinRule); const events = [ makeAccessEvent(accessRule), @@ -34,27 +38,25 @@ function mkStubRoomWithAccessRule(roomId: string, name: string, client: MatrixCl } describe("TchapJoinRule", () => { - - - beforeEach(() => { }); + beforeEach(() => {}); it("should render the tchap join rule with only private option", () => { - //build stub private room + //build stub private room const props = { room: mkStubRoomWithInviteRule("roomId", "roomName", createTestClient(), JoinRule.Invite), - closeSettingsFn(){}, - onError(error: Error){}, - } - + closeSettingsFn() {}, + onError(error: Error) {}, + }; + //arrange render(); //assert that spaces option is not here while private and public are - const publicText = "Public" - const privateText = "Private (invite only)" - const allowExternalText = "Allow external users to join this room" - const spaceText = "Anyone in a space can find and join" - + const publicText = "Public"; + const privateText = "Private (invite only)"; + const allowExternalText = "Allow external users to join this room"; + const spaceText = "Anyone in a space can find and join"; + expect(screen.queryByText(publicText)).toBe(null); expect(screen.queryByText(privateText)).toBeDefined(); expect(screen.queryByText(allowExternalText)).toBe(null); @@ -62,22 +64,23 @@ describe("TchapJoinRule", () => { }); it("should render the tchap join rule with only private option with restricted access rules", () => { - //build stub private room + //build stub private room const props = { - room: mkStubRoomWithAccessRule("roomId", "roomName", createTestClient(), JoinRule.Invite, TchapRoomAccessRule.Restricted), - closeSettingsFn(){}, - onError(error: Error){}, - } - + room: mkStubRoomWithAccessRule( + "roomId", "roomName", createTestClient(), JoinRule.Invite, TchapRoomAccessRule.Restricted), + closeSettingsFn() {}, + onError(error: Error) {}, + }; + //arrange render(); //assert that spaces option is not here while private and public are - const publicText = "Public" - const privateText = "Private (invite only)" - const allowExternalText = "Allow external users to join this room" - const spaceText = "Anyone in a space can find and join" - + const publicText = "Public"; + const privateText = "Private (invite only)"; + const allowExternalText = "Allow external users to join this room"; + const spaceText = "Anyone in a space can find and join"; + expect(screen.queryByText(publicText)).toBe(null); expect(screen.queryByText(privateText)).toBeDefined(); expect(screen.queryByText(allowExternalText)).toBeDefined(); @@ -87,13 +90,13 @@ describe("TchapJoinRule", () => { /* Impossible to mock a room to be considered as Public from TchapJoinRuleSettings point of view it("should render the tchap join rule with only public option", () => { - //build stub private room + //build stub private room const props = { room: mkStubRoomWithInviteRule("roomId", "roomName", createTestClient(), JoinRule.Public), closeSettingsFn(){}, onError(error: Error){}, } - + //arrange render(); @@ -101,11 +104,10 @@ describe("TchapJoinRule", () => { const privateText = "Private (invite only)" const publicText = "Public" const spaceText = "Anyone in a space can find and join" - + expect(screen.getByText(privateText)).toBe(null); expect(screen.getByText(publicText)).toBeDefined(); expect(screen.queryByText(spaceText)).toBe(null); }); */ - }); From 3b628e50d1c66fda85c34c6b68a7fd5e80f86461 Mon Sep 17 00:00:00 2001 From: Estelle Comment Date: Mon, 7 Nov 2022 17:55:49 +0100 Subject: [PATCH 5/7] fix linter --- test/unit-tests/lib/createTchapRoom-test.ts | 35 +++++++++++---------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/test/unit-tests/lib/createTchapRoom-test.ts b/test/unit-tests/lib/createTchapRoom-test.ts index 2ddd8dae16..5cfaf6023e 100644 --- a/test/unit-tests/lib/createTchapRoom-test.ts +++ b/test/unit-tests/lib/createTchapRoom-test.ts @@ -1,12 +1,9 @@ import { TchapRoomType } from '../../../src/@types/tchap'; import TchapCreateRoom from '../../../src/lib/createTchapRoom'; - - // todo(estellecomment) : these tests are redundant with TchapCreateRoomDialog-test. Either remove them or modify TchapCreateRoomDialog // to not edit state directly. describe("Create room options", () => { - beforeEach(() => { }); @@ -17,10 +14,10 @@ describe("Create room options", () => { creation_content: { "m.federate": true, }, - "initial_state": [ + initial_state: [ { "content": { - "rule": "restricted", + "rule": "restricted", }, "state_key": "", "type": "im.vector.room.access_rules", @@ -34,7 +31,8 @@ describe("Create room options", () => { encryption: true, historyVisibility: "invited", }; - expect(TchapCreateRoom.roomCreateOptions("testName", TchapRoomType.Private)).toStrictEqual(privateRoomExpectedOpts); + expect(TchapCreateRoom.roomCreateOptions("testName", TchapRoomType.Private)) + .toStrictEqual(privateRoomExpectedOpts); done(); }); @@ -45,10 +43,10 @@ describe("Create room options", () => { creation_content: { "m.federate": false, }, - "initial_state": [ + initial_state: [ { "content": { - "rule": "restricted", + "rule": "restricted", }, "state_key": "", "type": "im.vector.room.access_rules", @@ -62,7 +60,8 @@ describe("Create room options", () => { encryption: false, historyVisibility: "shared", }; - expect(TchapCreateRoom.roomCreateOptions("testName", TchapRoomType.Forum, false)).toStrictEqual(publicRoomWithoutFederationExpectedOpts); + expect(TchapCreateRoom.roomCreateOptions("testName", TchapRoomType.Forum, false)) + .toStrictEqual(publicRoomWithoutFederationExpectedOpts); done(); }); @@ -73,10 +72,10 @@ describe("Create room options", () => { creation_content: { "m.federate": true, }, - "initial_state": [ + initial_state: [ { "content": { - "rule": "restricted", + "rule": "restricted", }, "state_key": "", "type": "im.vector.room.access_rules", @@ -90,7 +89,8 @@ describe("Create room options", () => { encryption: false, historyVisibility: "shared", }; - expect(TchapCreateRoom.roomCreateOptions("testName", TchapRoomType.Forum, true)).toStrictEqual(publicRoomWithFederationExpectedOpts); + expect(TchapCreateRoom.roomCreateOptions("testName", TchapRoomType.Forum, true)) + .toStrictEqual(publicRoomWithFederationExpectedOpts); done(); }); @@ -101,10 +101,10 @@ describe("Create room options", () => { creation_content: { "m.federate": true, }, - "initial_state": [ + initial_state: [ { "content": { - "rule": "unrestricted", + "rule": "unrestricted", }, "state_key": "", "type": "im.vector.room.access_rules", @@ -118,12 +118,13 @@ describe("Create room options", () => { encryption: true, historyVisibility: "invited", }; - expect(TchapCreateRoom.roomCreateOptions("testName", TchapRoomType.External)).toStrictEqual(externalRoomExpectedOpts); + expect(TchapCreateRoom.roomCreateOptions("testName", TchapRoomType.External)) + .toStrictEqual(externalRoomExpectedOpts); done(); }); it("handles wrong inputs", (done) => { //todo - done() + done(); }); -}) \ No newline at end of file +}); From 24e088dc102ea91146aa6f30a94b3111cbf50565 Mon Sep 17 00:00:00 2001 From: Estelle Comment Date: Mon, 7 Nov 2022 18:02:27 +0100 Subject: [PATCH 6/7] more lint fixes --- src/util/TchapRoomUtils.ts | 2 +- test/unit-tests/util/TchapRoomUtils-test.ts | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/util/TchapRoomUtils.ts b/src/util/TchapRoomUtils.ts index 9f6aeb1480..1fa7ec693c 100644 --- a/src/util/TchapRoomUtils.ts +++ b/src/util/TchapRoomUtils.ts @@ -17,7 +17,7 @@ export default class TchapRoomUtils { return this.getTchapRoomTypeInternal(isEncrypted, tchapRoomAccessRule); } - private static getTchapRoomTypeInternal( + static getTchapRoomTypeInternal( isEncrypted: boolean, tchapRoomAccessRule: TchapRoomAccessRule): TchapRoomType { if (!isEncrypted) { return TchapRoomType.Forum; diff --git a/test/unit-tests/util/TchapRoomUtils-test.ts b/test/unit-tests/util/TchapRoomUtils-test.ts index 68e93e3128..682e0e16bf 100644 --- a/test/unit-tests/util/TchapRoomUtils-test.ts +++ b/test/unit-tests/util/TchapRoomUtils-test.ts @@ -1,22 +1,18 @@ -import { TchapRoomType } from '../../../src/@types/tchap'; +import { TchapRoomAccessRule, TchapRoomType } from '../../../src/@types/tchap'; import TchapRoomUtils from '../../../src/util/TchapRoomUtils'; - describe("Provides utils method to get room type and state", () => { - beforeEach(() => { }); it("returns room type depending on encryption and access rule", (done) => { - expect(TchapRoomUtils.getTchapRoomTypeInternal(true, "restricted")).toStrictEqual(TchapRoomType.Private); - expect(TchapRoomUtils.getTchapRoomTypeInternal(true, "unrestricted")).toStrictEqual(TchapRoomType.External); - expect(TchapRoomUtils.getTchapRoomTypeInternal(false)).toStrictEqual(TchapRoomType.Forum); - expect(TchapRoomUtils.getTchapRoomTypeInternal(true)).toStrictEqual(TchapRoomType.Unknown); + expect(TchapRoomUtils.getTchapRoomTypeInternal(true, TchapRoomAccessRule.Restricted)) + .toStrictEqual(TchapRoomType.Private); + expect(TchapRoomUtils.getTchapRoomTypeInternal(true, TchapRoomAccessRule.Unrestricted)) + .toStrictEqual(TchapRoomType.External); expect(TchapRoomUtils.getTchapRoomTypeInternal(true, "any")).toStrictEqual(TchapRoomType.Unknown); expect(TchapRoomUtils.getTchapRoomTypeInternal(true, undefined)).toStrictEqual(TchapRoomType.Unknown); done(); }); - - -}) \ No newline at end of file +}); From 4263216b62253e4b2b8cdcbdb9251c812d52769e Mon Sep 17 00:00:00 2001 From: Estelle Comment Date: Mon, 7 Nov 2022 18:08:01 +0100 Subject: [PATCH 7/7] More fixes --- test/.eslintrc.js | 2 +- .../components/views/settings/TchapJoinRuleSettings-test.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/.eslintrc.js b/test/.eslintrc.js index 4cc4659d7d..41371e2b61 100644 --- a/test/.eslintrc.js +++ b/test/.eslintrc.js @@ -2,4 +2,4 @@ module.exports = { env: { mocha: true, }, -} +}; diff --git a/test/unit-tests/components/views/settings/TchapJoinRuleSettings-test.tsx b/test/unit-tests/components/views/settings/TchapJoinRuleSettings-test.tsx index 7014e361cc..a1ac50ce5e 100644 --- a/test/unit-tests/components/views/settings/TchapJoinRuleSettings-test.tsx +++ b/test/unit-tests/components/views/settings/TchapJoinRuleSettings-test.tsx @@ -9,7 +9,7 @@ import TchapJoinRuleSettings from "../../../../../src/components/views/settings/ import { TchapRoomAccessRule, TchapRoomAccessRulesEventId } from "../../../../../src/@types/tchap"; function mkStubRoomWithInviteRule(roomId: string, name: string, client: MatrixClient, joinRule: JoinRule): Room { - const stubRoom: Room = mkStubRoom(roomId,name,client); + const stubRoom: Room = mkStubRoom(roomId, name, client); stubRoom.getJoinRule = jest.fn().mockReturnValue(joinRule); stubRoom.currentState.getJoinRule = jest.fn().mockReturnValue(joinRule); return stubRoom;