Conform more of the code base to strict null checking (#10147)
* Conform more of the code base to strict null checking * More strict fixes * More strict work * Fix missing optional type * Iterate
This commit is contained in:
parent
fa036a5080
commit
da7aa4055e
380 changed files with 682 additions and 694 deletions
|
@ -49,7 +49,7 @@ describe("<RoomSearchView/>", () => {
|
|||
stubClient();
|
||||
client = MatrixClientPeg.get();
|
||||
client.supportsThreads = jest.fn().mockReturnValue(true);
|
||||
room = new Room("!room:server", client, client.getUserId());
|
||||
room = new Room("!room:server", client, client.getUserId()!);
|
||||
mocked(client.getRoom).mockReturnValue(room);
|
||||
permalinkCreator = new RoomPermalinkCreator(room, room.roomId);
|
||||
|
||||
|
@ -92,7 +92,7 @@ describe("<RoomSearchView/>", () => {
|
|||
result: {
|
||||
room_id: room.roomId,
|
||||
event_id: "$2",
|
||||
sender: client.getUserId(),
|
||||
sender: client.getUserId()!,
|
||||
origin_server_ts: 1,
|
||||
content: { body: "Foo Test Bar", msgtype: "m.text" },
|
||||
type: EventType.RoomMessage,
|
||||
|
@ -103,7 +103,7 @@ describe("<RoomSearchView/>", () => {
|
|||
{
|
||||
room_id: room.roomId,
|
||||
event_id: "$1",
|
||||
sender: client.getUserId(),
|
||||
sender: client.getUserId()!,
|
||||
origin_server_ts: 1,
|
||||
content: { body: "Before", msgtype: "m.text" },
|
||||
type: EventType.RoomMessage,
|
||||
|
@ -113,7 +113,7 @@ describe("<RoomSearchView/>", () => {
|
|||
{
|
||||
room_id: room.roomId,
|
||||
event_id: "$3",
|
||||
sender: client.getUserId(),
|
||||
sender: client.getUserId()!,
|
||||
origin_server_ts: 1,
|
||||
content: { body: "After", msgtype: "m.text" },
|
||||
type: EventType.RoomMessage,
|
||||
|
@ -154,7 +154,7 @@ describe("<RoomSearchView/>", () => {
|
|||
result: {
|
||||
room_id: room.roomId,
|
||||
event_id: "$2",
|
||||
sender: client.getUserId(),
|
||||
sender: client.getUserId()!,
|
||||
origin_server_ts: 1,
|
||||
content: { body: "Foo Test Bar", msgtype: "m.text" },
|
||||
type: EventType.RoomMessage,
|
||||
|
@ -192,7 +192,7 @@ describe("<RoomSearchView/>", () => {
|
|||
result: {
|
||||
room_id: room.roomId,
|
||||
event_id: "$2",
|
||||
sender: client.getUserId(),
|
||||
sender: client.getUserId()!,
|
||||
origin_server_ts: 1,
|
||||
content: { body: "Foo Test Bar", msgtype: "m.text" },
|
||||
type: EventType.RoomMessage,
|
||||
|
@ -221,7 +221,7 @@ describe("<RoomSearchView/>", () => {
|
|||
result: {
|
||||
room_id: room.roomId,
|
||||
event_id: "$4",
|
||||
sender: client.getUserId(),
|
||||
sender: client.getUserId()!,
|
||||
origin_server_ts: 4,
|
||||
content: { body: "Potato", msgtype: "m.text" },
|
||||
type: EventType.RoomMessage,
|
||||
|
|
|
@ -43,20 +43,20 @@ describe("<TabbedView />", () => {
|
|||
|
||||
it("renders first tab as active tab when no initialTabId", () => {
|
||||
const { container } = render(getComponent());
|
||||
expect(getActiveTab(container).textContent).toEqual(generalTab.label);
|
||||
expect(getActiveTabBody(container).textContent).toEqual("general");
|
||||
expect(getActiveTab(container)?.textContent).toEqual(generalTab.label);
|
||||
expect(getActiveTabBody(container)?.textContent).toEqual("general");
|
||||
});
|
||||
|
||||
it("renders first tab as active tab when initialTabId is not valid", () => {
|
||||
const { container } = render(getComponent({ initialTabId: "bad-tab-id" }));
|
||||
expect(getActiveTab(container).textContent).toEqual(generalTab.label);
|
||||
expect(getActiveTabBody(container).textContent).toEqual("general");
|
||||
expect(getActiveTab(container)?.textContent).toEqual(generalTab.label);
|
||||
expect(getActiveTabBody(container)?.textContent).toEqual("general");
|
||||
});
|
||||
|
||||
it("renders initialTabId tab as active when valid", () => {
|
||||
const { container } = render(getComponent({ initialTabId: securityTab.id }));
|
||||
expect(getActiveTab(container).textContent).toEqual(securityTab.label);
|
||||
expect(getActiveTabBody(container).textContent).toEqual("security");
|
||||
expect(getActiveTab(container)?.textContent).toEqual(securityTab.label);
|
||||
expect(getActiveTabBody(container)?.textContent).toEqual("security");
|
||||
});
|
||||
|
||||
it("renders without error when there are no tabs", () => {
|
||||
|
@ -71,8 +71,8 @@ describe("<TabbedView />", () => {
|
|||
fireEvent.click(getByTestId(getTabTestId(securityTab)));
|
||||
});
|
||||
|
||||
expect(getActiveTab(container).textContent).toEqual(securityTab.label);
|
||||
expect(getActiveTabBody(container).textContent).toEqual("security");
|
||||
expect(getActiveTab(container)?.textContent).toEqual(securityTab.label);
|
||||
expect(getActiveTabBody(container)?.textContent).toEqual("security");
|
||||
});
|
||||
|
||||
it("calls onchange on on tab click", () => {
|
||||
|
@ -90,29 +90,29 @@ describe("<TabbedView />", () => {
|
|||
// start with middle tab active
|
||||
const { container, rerender } = render(getComponent({ initialTabId: labsTab.id }));
|
||||
|
||||
expect(getActiveTab(container).textContent).toEqual(labsTab.label);
|
||||
expect(getActiveTab(container)?.textContent).toEqual(labsTab.label);
|
||||
|
||||
rerender(getComponent({ tabs: [labsTab, generalTab, securityTab] }));
|
||||
|
||||
// labs tab still active
|
||||
expect(getActiveTab(container).textContent).toEqual(labsTab.label);
|
||||
expect(getActiveTab(container)?.textContent).toEqual(labsTab.label);
|
||||
});
|
||||
|
||||
it("does not reactivate inititalTabId on rerender", () => {
|
||||
const { container, getByTestId, rerender } = render(getComponent());
|
||||
|
||||
expect(getActiveTab(container).textContent).toEqual(generalTab.label);
|
||||
expect(getActiveTab(container)?.textContent).toEqual(generalTab.label);
|
||||
|
||||
// make security tab active
|
||||
act(() => {
|
||||
fireEvent.click(getByTestId(getTabTestId(securityTab)));
|
||||
});
|
||||
expect(getActiveTab(container).textContent).toEqual(securityTab.label);
|
||||
expect(getActiveTab(container)?.textContent).toEqual(securityTab.label);
|
||||
|
||||
// rerender with new tab location
|
||||
rerender(getComponent({ tabLocation: TabLocation.TOP }));
|
||||
|
||||
// still security tab
|
||||
expect(getActiveTab(container).textContent).toEqual(securityTab.label);
|
||||
expect(getActiveTab(container)?.textContent).toEqual(securityTab.label);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue