From 4979ed87b11cf4be73f7e556c1215e76c7bbbfe3 Mon Sep 17 00:00:00 2001
From: "D. Ror" <imnasnainaec@gmail.com>
Date: Fri, 23 Feb 2024 15:06:49 -0500
Subject: [PATCH] Fix uncalled/impotent test functions (#2945)

---
 .../AppBar/tests/NavigationButtons.test.tsx   | 10 +++---
 .../AppBar/tests/SpeakerMenu.test.tsx         |  2 +-
 .../DataEntryTable/tests/index.test.tsx       |  6 ++--
 src/components/DataEntry/tests/index.test.tsx |  4 +--
 .../PasswordReset/tests/ResetPage.test.tsx    |  2 +-
 .../tests/ProjectImport.test.tsx              |  4 +--
 .../tests/ProjectSpeakersList.test.tsx        |  2 +-
 .../ProjectUsers/tests/SortOptions.test.tsx   |  1 -
 .../tests/SpeakerConsentListItemIcon.test.tsx | 34 +++++++++----------
 .../Redux/tests/ReviewEntriesActions.test.tsx |  6 ++--
 src/utilities/tests/dictionaryLoader.test.ts  |  4 +--
 11 files changed, 35 insertions(+), 40 deletions(-)

diff --git a/src/components/AppBar/tests/NavigationButtons.test.tsx b/src/components/AppBar/tests/NavigationButtons.test.tsx
index 2136106f80..429fdfeed0 100644
--- a/src/components/AppBar/tests/NavigationButtons.test.tsx
+++ b/src/components/AppBar/tests/NavigationButtons.test.tsx
@@ -27,7 +27,7 @@ const mockStore = configureMockStore()({
 
 let testRenderer: renderer.ReactTestRenderer;
 let entryButton: ReactTestInstance;
-let cleanButton: ReactTestInstance;
+let cleanButton: ReactTestInstance | null;
 
 const renderNavButtons = async (
   path: Path,
@@ -57,9 +57,7 @@ const renderNavButtonsWithPermission = async (
   const cleanupButtons = testRenderer.root.findAllByProps({
     id: dataCleanupButtonId,
   });
-  if (cleanupButtons.length) {
-    cleanButton = cleanupButtons[0];
-  }
+  cleanButton = cleanupButtons.length ? cleanupButtons[0] : null;
 };
 
 beforeEach(() => {
@@ -74,9 +72,9 @@ describe("NavigationButtons", () => {
         perm === Permission.CharacterInventory ||
         perm === Permission.MergeAndReviewEntries
       ) {
-        expect(cleanButton).toBeTruthy;
+        expect(cleanButton).toBeTruthy();
       } else {
-        expect(cleanButton).toBeUndefined;
+        expect(cleanButton).toBeNull();
       }
     }
   });
diff --git a/src/components/AppBar/tests/SpeakerMenu.test.tsx b/src/components/AppBar/tests/SpeakerMenu.test.tsx
index f1f19ed782..cd8c94b536 100644
--- a/src/components/AppBar/tests/SpeakerMenu.test.tsx
+++ b/src/components/AppBar/tests/SpeakerMenu.test.tsx
@@ -54,7 +54,7 @@ describe("SpeakerMenuList", () => {
   it("has one disabled menu item if no speakers", async () => {
     await renderMenuList();
     const menuItem = testRenderer.root.findByType(MenuItem);
-    expect(menuItem).toBeDisabled;
+    expect(menuItem.props.disabled).toBeTruthy();
   });
 
   it("has divider and one more menu item than speakers", async () => {
diff --git a/src/components/DataEntry/DataEntryTable/tests/index.test.tsx b/src/components/DataEntry/DataEntryTable/tests/index.test.tsx
index baf6075ee7..067d47be7b 100644
--- a/src/components/DataEntry/DataEntryTable/tests/index.test.tsx
+++ b/src/components/DataEntry/DataEntryTable/tests/index.test.tsx
@@ -151,7 +151,6 @@ describe("DataEntryTable", () => {
     it("creates word when new entry has vernacular", async () => {
       expect(mockCreateWord).not.toHaveBeenCalled();
       testHandle = testRenderer.root.findByType(NewEntry);
-      expect(testHandle).not.toBeNull;
       // Set newVern but not newGloss.
       await act(async () => testHandle.props.setNewVern("hasVern"));
       testHandle = testRenderer.root.findByProps({ id: exitButtonId });
@@ -161,7 +160,6 @@ describe("DataEntryTable", () => {
 
     it("doesn't create word when new entry has no vernacular", async () => {
       testHandle = testRenderer.root.findByType(NewEntry);
-      expect(testHandle).not.toBeNull;
       // Set newGloss but not newVern.
       await act(async () => testHandle.props.setNewGloss("hasGloss"));
       testHandle = testRenderer.root.findByProps({ id: exitButtonId });
@@ -231,8 +229,8 @@ describe("DataEntryTable", () => {
 
   describe("makeSemDomCurrent", () => {
     it("adds timestamp and the current user", () => {
-      expect(mockSemDom.created).toBeUndefined;
-      expect(mockSemDom.userId).toBeUndefined;
+      expect(mockSemDom.created).toBeUndefined();
+      expect(mockSemDom.userId).toBeUndefined();
 
       const currentDom = makeSemDomCurrent(mockSemDom);
       expect(currentDom.created).not.toBeUndefined();
diff --git a/src/components/DataEntry/tests/index.test.tsx b/src/components/DataEntry/tests/index.test.tsx
index a459dc7ef9..0e272443c8 100644
--- a/src/components/DataEntry/tests/index.test.tsx
+++ b/src/components/DataEntry/tests/index.test.tsx
@@ -58,13 +58,13 @@ describe("DataEntry", () => {
   it("displays TreeView when state says the tree is open", async () => {
     await renderDataEntry({ currentDomain: mockDomain, open: true });
     const dialog = testHandle.root.findByProps({ id: treeViewDialogId });
-    expect(dialog.props.open).toBeTruthy;
+    expect(dialog.props.open).toBeTruthy();
   });
 
   it("doesn't displays TreeView when state says the tree is closed", async () => {
     await renderDataEntry({ currentDomain: mockDomain, open: false });
     const dialog = testHandle.root.findByProps({ id: treeViewDialogId });
-    expect(dialog.props.open).toBeFalsy;
+    expect(dialog.props.open).toBeFalsy();
   });
 
   it("dispatches to open the tree", async () => {
diff --git a/src/components/PasswordReset/tests/ResetPage.test.tsx b/src/components/PasswordReset/tests/ResetPage.test.tsx
index 85468addb8..ae7dd7bed7 100644
--- a/src/components/PasswordReset/tests/ResetPage.test.tsx
+++ b/src/components/PasswordReset/tests/ResetPage.test.tsx
@@ -178,6 +178,6 @@ describe("PasswordReset", () => {
       expect(screen.queryAllByTestId(id)).toHaveLength(0);
     }
     // The textId will show up as text because t() is mocked to return its input.
-    expect(screen.queryAllByText("passwordReset.invalidURL")).toBeTruthy;
+    expect(screen.queryAllByText("passwordReset.invalidURL")).toBeTruthy();
   });
 });
diff --git a/src/components/ProjectSettings/tests/ProjectImport.test.tsx b/src/components/ProjectSettings/tests/ProjectImport.test.tsx
index 6288e1185a..aef6b9050c 100644
--- a/src/components/ProjectSettings/tests/ProjectImport.test.tsx
+++ b/src/components/ProjectSettings/tests/ProjectImport.test.tsx
@@ -27,7 +27,7 @@ const renderImport = async (): Promise<void> => {
 describe("ProjectImport", () => {
   it("upload button disabled when no file selected", async () => {
     await renderImport();
-    expect(uploadButton.props.disabled).toBeTruthy;
+    expect(uploadButton.props.disabled).toBeTruthy();
   });
 
   it("upload button enabled when file selected", async () => {
@@ -35,6 +35,6 @@ describe("ProjectImport", () => {
     const selectButton = testRenderer.root.findByType(FileInputButton);
     const mockFile = { name: "name-of-a.file" } as File;
     await renderer.act(async () => selectButton.props.updateFile(mockFile));
-    expect(uploadButton.props.disabled).toBeFalsy;
+    expect(uploadButton.props.disabled).toBeFalsy();
   });
 });
diff --git a/src/components/ProjectUsers/tests/ProjectSpeakersList.test.tsx b/src/components/ProjectUsers/tests/ProjectSpeakersList.test.tsx
index 9a42c9368b..ac4cade32e 100644
--- a/src/components/ProjectUsers/tests/ProjectSpeakersList.test.tsx
+++ b/src/components/ProjectUsers/tests/ProjectSpeakersList.test.tsx
@@ -44,6 +44,6 @@ describe("ProjectSpeakersList", () => {
     expect(testRenderer.root.findAllByType(SpeakerListItem)).toHaveLength(
       mockSpeakers.length
     );
-    expect(testRenderer.root.findByType(AddSpeakerListItem)).toBeTruthy;
+    expect(testRenderer.root.findByType(AddSpeakerListItem)).toBeTruthy();
   });
 });
diff --git a/src/components/ProjectUsers/tests/SortOptions.test.tsx b/src/components/ProjectUsers/tests/SortOptions.test.tsx
index 2ca50cf237..38d41b7531 100644
--- a/src/components/ProjectUsers/tests/SortOptions.test.tsx
+++ b/src/components/ProjectUsers/tests/SortOptions.test.tsx
@@ -36,7 +36,6 @@ describe("SortOptions", () => {
     const mockReverse = jest.fn();
     renderSortOptions({ onReverseClick: mockReverse });
     const button = testRenderer.root.findByProps({ id: reverseButtonId });
-    expect(button).not.toBeNull();
     button.props.onClick();
     expect(mockReverse).toHaveBeenCalledTimes(1);
   });
diff --git a/src/components/ProjectUsers/tests/SpeakerConsentListItemIcon.test.tsx b/src/components/ProjectUsers/tests/SpeakerConsentListItemIcon.test.tsx
index 64ab376633..13ae4e0646 100644
--- a/src/components/ProjectUsers/tests/SpeakerConsentListItemIcon.test.tsx
+++ b/src/components/ProjectUsers/tests/SpeakerConsentListItemIcon.test.tsx
@@ -66,9 +66,9 @@ describe("SpeakerConsentListItemIcon", () => {
         ...mockSpeaker,
         consent: ConsentType.None,
       });
-      expect(screen.queryByTestId(ListItemIconId.AddConsent)).not.toBeNull;
-      expect(screen.queryByTestId(ListItemIconId.PlayAudio)).toBeNull;
-      expect(screen.queryByTestId(ListItemIconId.ShowImage)).toBeNull;
+      expect(screen.queryByTestId(ListItemIconId.AddConsent)).not.toBeNull();
+      expect(screen.queryByTestId(ListItemIconId.PlayAudio)).toBeNull();
+      expect(screen.queryByTestId(ListItemIconId.ShowImage)).toBeNull();
     });
 
     it("opens menu when clicked", async () => {
@@ -77,14 +77,14 @@ describe("SpeakerConsentListItemIcon", () => {
         ...mockSpeaker,
         consent: ConsentType.None,
       });
-      expect(screen.queryByRole("menu")).toBeNull;
-      expect(screen.queryByTestId(ListItemIconId.RecordAudio)).toBeNull;
-      expect(screen.queryByTestId(ListItemIconId.UploadAudio)).toBeNull;
+      expect(screen.queryByRole("menu")).toBeNull();
+      expect(screen.queryByTestId(ListItemIconId.RecordAudio)).toBeNull();
+      expect(screen.queryByTestId(ListItemIconId.UploadAudio)).toBeNull();
 
       await agent.click(screen.getByRole("button"));
-      expect(screen.queryByRole("menu")).not.toBeNull;
-      expect(screen.queryByTestId(ListItemIconId.RecordAudio)).not.toBeNull;
-      expect(screen.queryByTestId(ListItemIconId.UploadAudio)).not.toBeNull;
+      expect(screen.queryByRole("menu")).not.toBeNull();
+      expect(screen.queryByTestId(ListItemIconId.RecordAudio)).not.toBeNull();
+      expect(screen.queryByTestId(ListItemIconId.UploadAudio)).not.toBeNull();
     });
   });
 
@@ -94,9 +94,9 @@ describe("SpeakerConsentListItemIcon", () => {
         ...mockSpeaker,
         consent: ConsentType.Audio,
       });
-      expect(screen.queryByTestId(ListItemIconId.AddConsent)).toBeNull;
-      expect(screen.queryByTestId(ListItemIconId.PlayAudio)).not.toBeNull;
-      expect(screen.queryByTestId(ListItemIconId.ShowImage)).toBeNull;
+      expect(screen.queryByTestId(ListItemIconId.AddConsent)).toBeNull();
+      expect(screen.queryByTestId(ListItemIconId.PlayAudio)).not.toBeNull();
+      expect(screen.queryByTestId(ListItemIconId.ShowImage)).toBeNull();
     });
   });
 
@@ -106,9 +106,9 @@ describe("SpeakerConsentListItemIcon", () => {
         ...mockSpeaker,
         consent: ConsentType.Image,
       });
-      expect(screen.queryByTestId(ListItemIconId.AddConsent)).toBeNull;
-      expect(screen.queryByTestId(ListItemIconId.PlayAudio)).toBeNull;
-      expect(screen.queryByTestId(ListItemIconId.ShowImage)).not.toBeNull;
+      expect(screen.queryByTestId(ListItemIconId.AddConsent)).toBeNull();
+      expect(screen.queryByTestId(ListItemIconId.PlayAudio)).toBeNull();
+      expect(screen.queryByTestId(ListItemIconId.ShowImage)).not.toBeNull();
     });
 
     it("opens dialog when clicked", async () => {
@@ -117,10 +117,10 @@ describe("SpeakerConsentListItemIcon", () => {
         ...mockSpeaker,
         consent: ConsentType.Image,
       });
-      expect(screen.queryAllByRole("dialog")).toBeNull;
+      expect(screen.queryByRole("dialog")).toBeNull();
 
       await agent.click(screen.getByRole("button"));
-      expect(screen.queryAllByRole("dialog")).not.toBeNull;
+      expect(screen.queryByRole("dialog")).not.toBeNull();
     });
   });
 });
diff --git a/src/goals/ReviewEntries/Redux/tests/ReviewEntriesActions.test.tsx b/src/goals/ReviewEntries/Redux/tests/ReviewEntriesActions.test.tsx
index 9380aae120..a078a11340 100644
--- a/src/goals/ReviewEntries/Redux/tests/ReviewEntriesActions.test.tsx
+++ b/src/goals/ReviewEntries/Redux/tests/ReviewEntriesActions.test.tsx
@@ -217,7 +217,7 @@ describe("ReviewEntriesActions", () => {
 
       // Verify the replacement word in state has the audio removed
       const words = store.getState().reviewEntriesState.words;
-      expect(words.find((w) => w.id === wordId)).toBeNull;
+      expect(words.find((w) => w.id === wordId)).toBeUndefined();
       const wordInState = words.find((w) => w.id === newId);
       expect(wordInState?.audio).toHaveLength(0);
     });
@@ -247,7 +247,7 @@ describe("ReviewEntriesActions", () => {
 
       // Verify the replacement word in state has the updated speaker id
       const words = store.getState().reviewEntriesState.words;
-      expect(words.find((w) => w.id === wordId)).toBeNull;
+      expect(words.find((w) => w.id === wordId)).toBeUndefined();
       const audioInState = words.find((w) => w.id === newId)?.audio;
       expect(audioInState).toHaveLength(1);
       expect(audioInState![0].speakerId).toEqual(speakerId);
@@ -276,7 +276,7 @@ describe("ReviewEntriesActions", () => {
 
       // Verify the replacement word in state has the audio added
       const words = store.getState().reviewEntriesState.words;
-      expect(words.find((w) => w.id === wordId)).toBeNull;
+      expect(words.find((w) => w.id === wordId)).toBeUndefined();
       const audioInState = words.find((w) => w.id === newId)?.audio;
       expect(audioInState).toHaveLength(1);
       expect(audioInState![0].fileName).toEqual(pro.fileName);
diff --git a/src/utilities/tests/dictionaryLoader.test.ts b/src/utilities/tests/dictionaryLoader.test.ts
index 2ba97d462f..9d84027bc3 100644
--- a/src/utilities/tests/dictionaryLoader.test.ts
+++ b/src/utilities/tests/dictionaryLoader.test.ts
@@ -57,8 +57,8 @@ describe("DictionaryLoader", () => {
 
     it("loads nothing for empty or non-existent key", async () => {
       const loader = new DictionaryLoader(bcp47);
-      expect(await loader.loadDictPart("")).toBeUndefined;
-      expect(await loader.loadDictPart("not-a-key")).toBeUndefined;
+      expect(await loader.loadDictPart("")).toBeUndefined();
+      expect(await loader.loadDictPart("not-a-key")).toBeUndefined();
     });
 
     it("doesn't load the same part more than once", async () => {