From df3b8f359f2b7cf06ba566ad76dd0fb0aa9ddf40 Mon Sep 17 00:00:00 2001
From: Laurent Deketelaere <10886527-ali_o_kan@users.noreply.gitlab.com>
Date: Wed, 21 Sep 2022 19:32:07 +0000
Subject: [PATCH] Avoid usage of toBeTruthy/toBeFalsy in `spec/frontend/` part
 2

---
 spec/frontend/blob/blob_blame_link_spec.js    |  6 ++---
 .../blob/components/blob_content_spec.js      |  4 ++--
 .../components/deploy_freeze_modal_spec.js    |  6 ++---
 .../components/delete_button_spec.js          |  6 ++---
 .../design_notes/design_reply_form_spec.js    | 24 +++++++++----------
 .../groups/store/groups_store_spec.js         | 10 ++++----
 .../ide/components/terminal/terminal_spec.js  |  2 +-
 spec/frontend/ide/stores/actions_spec.js      |  4 ++--
 .../stores/modules/commit/mutations_spec.js   |  2 +-
 .../ide/stores/mutations/tree_spec.js         |  4 ++--
 spec/frontend/ide/stores/mutations_spec.js    |  8 +++----
 spec/frontend/smart_interval_spec.js          | 16 ++++++-------
 spec/frontend/user_popovers_spec.js           |  4 ++--
 13 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/spec/frontend/blob/blob_blame_link_spec.js b/spec/frontend/blob/blob_blame_link_spec.js
index 0d19177a11ff2..060e880352093 100644
--- a/spec/frontend/blob/blob_blame_link_spec.js
+++ b/spec/frontend/blob/blob_blame_link_spec.js
@@ -29,19 +29,19 @@ describe('Blob links', () => {
   it('adds wrapper elements with correct classes', () => {
     const wrapper = document.querySelector('.line-links');
 
-    expect(wrapper).toBeTruthy();
+    expect(wrapper).not.toBeNull();
     expect(wrapper.classList).toContain('diff-line-num');
   });
 
   it('adds blame link with correct classes and path', () => {
     const blameLink = document.querySelector('.file-line-blame');
-    expect(blameLink).toBeTruthy();
+    expect(blameLink).not.toBeNull();
     expect(blameLink.getAttribute('href')).toBe('/blamePath#L5');
   });
 
   it('adds line link within wraper with correct classes and path', () => {
     const lineLink = document.querySelector('.file-line-num');
-    expect(lineLink).toBeTruthy();
+    expect(lineLink).not.toBeNull();
     expect(lineLink.getAttribute('href')).toBe('#L5');
   });
 });
diff --git a/spec/frontend/blob/components/blob_content_spec.js b/spec/frontend/blob/components/blob_content_spec.js
index 788ee0a86ab90..f7b819b6e943b 100644
--- a/spec/frontend/blob/components/blob_content_spec.js
+++ b/spec/frontend/blob/components/blob_content_spec.js
@@ -91,13 +91,13 @@ describe('Blob Content component', () => {
       it(`properly proxies ${BLOB_RENDER_EVENT_LOAD} event`, () => {
         expect(wrapper.emitted(BLOB_RENDER_EVENT_LOAD)).toBeUndefined();
         findErrorEl().vm.$emit(BLOB_RENDER_EVENT_LOAD);
-        expect(wrapper.emitted(BLOB_RENDER_EVENT_LOAD)).toBeTruthy();
+        expect(wrapper.emitted(BLOB_RENDER_EVENT_LOAD)).toHaveLength(1);
       });
 
       it(`properly proxies ${BLOB_RENDER_EVENT_SHOW_SOURCE} event`, () => {
         expect(wrapper.emitted(BLOB_RENDER_EVENT_SHOW_SOURCE)).toBeUndefined();
         findErrorEl().vm.$emit(BLOB_RENDER_EVENT_SHOW_SOURCE);
-        expect(wrapper.emitted(BLOB_RENDER_EVENT_SHOW_SOURCE)).toBeTruthy();
+        expect(wrapper.emitted(BLOB_RENDER_EVENT_SHOW_SOURCE)).toHaveLength(1);
       });
     });
   });
diff --git a/spec/frontend/deploy_freeze/components/deploy_freeze_modal_spec.js b/spec/frontend/deploy_freeze/components/deploy_freeze_modal_spec.js
index bbafdc000dbfe..b8c979a41575f 100644
--- a/spec/frontend/deploy_freeze/components/deploy_freeze_modal_spec.js
+++ b/spec/frontend/deploy_freeze/components/deploy_freeze_modal_spec.js
@@ -52,7 +52,7 @@ describe('Deploy freeze modal', () => {
 
   describe('Basic interactions', () => {
     it('button is disabled when freeze period is invalid', () => {
-      expect(submitDeployFreezeButton().attributes('disabled')).toBeTruthy();
+      expect(submitDeployFreezeButton().attributes('disabled')).toBe('true');
     });
   });
 
@@ -92,7 +92,7 @@ describe('Deploy freeze modal', () => {
       });
 
       it('disables the add deploy freeze button', () => {
-        expect(submitDeployFreezeButton().attributes('disabled')).toBeTruthy();
+        expect(submitDeployFreezeButton().attributes('disabled')).toBe('true');
       });
     });
 
@@ -103,7 +103,7 @@ describe('Deploy freeze modal', () => {
       });
 
       it('does not disable the submit button', () => {
-        expect(submitDeployFreezeButton().attributes('disabled')).toBeFalsy();
+        expect(submitDeployFreezeButton().attributes('disabled')).toBeUndefined();
       });
     });
   });
diff --git a/spec/frontend/design_management/components/delete_button_spec.js b/spec/frontend/design_management/components/delete_button_spec.js
index cee1eec792dc1..426a61f5a477a 100644
--- a/spec/frontend/design_management/components/delete_button_spec.js
+++ b/spec/frontend/design_management/components/delete_button_spec.js
@@ -29,12 +29,12 @@ describe('Batch delete button component', () => {
     createComponent();
 
     expect(findButton().exists()).toBe(true);
-    expect(findButton().attributes('disabled')).toBeFalsy();
+    expect(findButton().attributes('disabled')).toBeUndefined();
   });
 
   it('renders disabled button when design is deleting', () => {
     createComponent({ isDeleting: true });
-    expect(findButton().attributes('disabled')).toBeTruthy();
+    expect(findButton().attributes('disabled')).toBe('true');
   });
 
   it('emits `delete-selected-designs` event on modal ok click', async () => {
@@ -45,7 +45,7 @@ describe('Batch delete button component', () => {
     findModal().vm.$emit('ok');
 
     await nextTick();
-    expect(wrapper.emitted('delete-selected-designs')).toBeTruthy();
+    expect(wrapper.emitted('delete-selected-designs')).toHaveLength(1);
   });
 
   it('renders slot content', () => {
diff --git a/spec/frontend/design_management/components/design_notes/design_reply_form_spec.js b/spec/frontend/design_management/components/design_notes/design_reply_form_spec.js
index e36f5c79e3eaa..83804f28f5941 100644
--- a/spec/frontend/design_management/components/design_notes/design_reply_form_spec.js
+++ b/spec/frontend/design_management/components/design_notes/design_reply_form_spec.js
@@ -102,7 +102,7 @@ describe('Design reply form component', () => {
     });
 
     it('submit button is disabled', () => {
-      expect(findSubmitButton().attributes().disabled).toBeTruthy();
+      expect(findSubmitButton().attributes().disabled).toBe('disabled');
     });
 
     it('does not emit submitForm event on textarea ctrl+enter keydown', async () => {
@@ -111,7 +111,7 @@ describe('Design reply form component', () => {
       });
 
       await nextTick();
-      expect(wrapper.emitted('submit-form')).toBeFalsy();
+      expect(wrapper.emitted('submit-form')).toBeUndefined();
     });
 
     it('does not emit submitForm event on textarea meta+enter keydown', async () => {
@@ -120,13 +120,13 @@ describe('Design reply form component', () => {
       });
 
       await nextTick();
-      expect(wrapper.emitted('submit-form')).toBeFalsy();
+      expect(wrapper.emitted('submit-form')).toBeUndefined();
     });
 
     it('emits cancelForm event on pressing escape button on textarea', () => {
       findTextarea().trigger('keyup.esc');
 
-      expect(wrapper.emitted('cancel-form')).toBeTruthy();
+      expect(wrapper.emitted('cancel-form')).toHaveLength(1);
     });
 
     it('emits cancelForm event on clicking Cancel button', () => {
@@ -144,7 +144,7 @@ describe('Design reply form component', () => {
     });
 
     it('submit button is enabled', () => {
-      expect(findSubmitButton().attributes().disabled).toBeFalsy();
+      expect(findSubmitButton().attributes().disabled).toBeUndefined();
     });
 
     it('emits submitForm event on Comment button click', async () => {
@@ -153,7 +153,7 @@ describe('Design reply form component', () => {
       findSubmitButton().vm.$emit('click');
 
       await nextTick();
-      expect(wrapper.emitted('submit-form')).toBeTruthy();
+      expect(wrapper.emitted('submit-form')).toHaveLength(1);
       expect(autosaveResetSpy).toHaveBeenCalled();
     });
 
@@ -165,7 +165,7 @@ describe('Design reply form component', () => {
       });
 
       await nextTick();
-      expect(wrapper.emitted('submit-form')).toBeTruthy();
+      expect(wrapper.emitted('submit-form')).toHaveLength(1);
       expect(autosaveResetSpy).toHaveBeenCalled();
     });
 
@@ -177,7 +177,7 @@ describe('Design reply form component', () => {
       });
 
       await nextTick();
-      expect(wrapper.emitted('submit-form')).toBeTruthy();
+      expect(wrapper.emitted('submit-form')).toHaveLength(1);
       expect(autosaveResetSpy).toHaveBeenCalled();
     });
 
@@ -185,13 +185,13 @@ describe('Design reply form component', () => {
       findTextarea().setValue('test2');
 
       await nextTick();
-      expect(wrapper.emitted('input')).toBeTruthy();
+      expect(wrapper.emitted('input')).toEqual([['test'], ['test2']]);
     });
 
     it('emits cancelForm event on Escape key if text was not changed', () => {
       findTextarea().trigger('keyup.esc');
 
-      expect(wrapper.emitted('cancel-form')).toBeTruthy();
+      expect(wrapper.emitted('cancel-form')).toHaveLength(1);
     });
 
     it('opens confirmation modal on Escape key when text has changed', async () => {
@@ -205,7 +205,7 @@ describe('Design reply form component', () => {
     it('emits cancelForm event on Cancel button click if text was not changed', () => {
       findCancelButton().trigger('click');
 
-      expect(wrapper.emitted('cancel-form')).toBeTruthy();
+      expect(wrapper.emitted('cancel-form')).toHaveLength(1);
     });
 
     it('opens confirmation modal on Cancel button click when text has changed', async () => {
@@ -222,7 +222,7 @@ describe('Design reply form component', () => {
       findTextarea().trigger('keyup.esc');
       findModal().vm.$emit('ok');
 
-      expect(wrapper.emitted('cancel-form')).toBeTruthy();
+      expect(wrapper.emitted('cancel-form')).toHaveLength(2);
       expect(autosaveResetSpy).toHaveBeenCalled();
     });
   });
diff --git a/spec/frontend/groups/store/groups_store_spec.js b/spec/frontend/groups/store/groups_store_spec.js
index 8ac5d7099f15d..ce1791d006255 100644
--- a/spec/frontend/groups/store/groups_store_spec.js
+++ b/spec/frontend/groups/store/groups_store_spec.js
@@ -16,13 +16,13 @@ describe('ProjectsStore', () => {
       store = new GroupsStore();
 
       expect(Object.keys(store.state).length).toBe(2);
-      expect(Array.isArray(store.state.groups)).toBeTruthy();
+      expect(Array.isArray(store.state.groups)).toBe(true);
       expect(Object.keys(store.state.pageInfo).length).toBe(0);
-      expect(store.hideProjects).toBeFalsy();
+      expect(store.hideProjects).toBe(false);
 
       store = new GroupsStore({ hideProjects: true });
 
-      expect(store.hideProjects).toBeTruthy();
+      expect(store.hideProjects).toBe(true);
     });
   });
 
@@ -65,8 +65,8 @@ describe('ProjectsStore', () => {
       expect(store.formatGroupItem).toHaveBeenCalledWith(expect.any(Object));
       expect(mockParentGroupItem.children.length).toBe(1);
       expect(Object.keys(mockParentGroupItem.children[0]).indexOf('fullName')).toBeGreaterThan(-1);
-      expect(mockParentGroupItem.isOpen).toBeTruthy();
-      expect(mockParentGroupItem.isChildrenLoading).toBeFalsy();
+      expect(mockParentGroupItem.isOpen).toBe(true);
+      expect(mockParentGroupItem.isChildrenLoading).toBe(false);
     });
   });
 
diff --git a/spec/frontend/ide/components/terminal/terminal_spec.js b/spec/frontend/ide/components/terminal/terminal_spec.js
index 4da3e1910e9ec..0d22f7f73fe9a 100644
--- a/spec/frontend/ide/components/terminal/terminal_spec.js
+++ b/spec/frontend/ide/components/terminal/terminal_spec.js
@@ -171,7 +171,7 @@ describe('IDE Terminal', () => {
 
     it('creates the terminal', () => {
       expect(GLTerminal).toHaveBeenCalledWith(wrapper.vm.$refs.terminal);
-      expect(wrapper.vm.glterminal).toBeTruthy();
+      expect(wrapper.vm.glterminal).toBeInstanceOf(GLTerminal);
     });
 
     describe('scroll listener', () => {
diff --git a/spec/frontend/ide/stores/actions_spec.js b/spec/frontend/ide/stores/actions_spec.js
index f6d54491d772e..21480ef873f12 100644
--- a/spec/frontend/ide/stores/actions_spec.js
+++ b/spec/frontend/ide/stores/actions_spec.js
@@ -138,7 +138,7 @@ describe('Multi-file store actions', () => {
           name: 'testing/test',
           type: 'tree',
         });
-        expect(tree.tree[0].tempFile).toBeTruthy();
+        expect(tree.tree[0].tempFile).toBe(true);
         expect(tree.tree[0].name).toBe('test');
         expect(tree.tree[0].type).toBe('tree');
       });
@@ -173,7 +173,7 @@ describe('Multi-file store actions', () => {
         });
         const f = store.state.entries[name];
 
-        expect(f.tempFile).toBeTruthy();
+        expect(f.tempFile).toBe(true);
         expect(f.mimeType).toBe('test/mime');
         expect(store.state.trees['abcproject/mybranch'].tree.length).toBe(1);
       });
diff --git a/spec/frontend/ide/stores/modules/commit/mutations_spec.js b/spec/frontend/ide/stores/modules/commit/mutations_spec.js
index 50342832d751b..d277157e73759 100644
--- a/spec/frontend/ide/stores/modules/commit/mutations_spec.js
+++ b/spec/frontend/ide/stores/modules/commit/mutations_spec.js
@@ -37,7 +37,7 @@ describe('IDE commit module mutations', () => {
     it('updates submitCommitLoading', () => {
       mutations.UPDATE_LOADING(state, true);
 
-      expect(state.submitCommitLoading).toBeTruthy();
+      expect(state.submitCommitLoading).toBe(true);
     });
   });
 
diff --git a/spec/frontend/ide/stores/mutations/tree_spec.js b/spec/frontend/ide/stores/mutations/tree_spec.js
index 6935e57578f1d..a8c0d7ba2c85b 100644
--- a/spec/frontend/ide/stores/mutations/tree_spec.js
+++ b/spec/frontend/ide/stores/mutations/tree_spec.js
@@ -17,11 +17,11 @@ describe('Multi-file store tree mutations', () => {
     it('toggles tree open', () => {
       mutations.TOGGLE_TREE_OPEN(localState, localTree.path);
 
-      expect(localTree.opened).toBeTruthy();
+      expect(localTree.opened).toBe(true);
 
       mutations.TOGGLE_TREE_OPEN(localState, localTree.path);
 
-      expect(localTree.opened).toBeFalsy();
+      expect(localTree.opened).toBe(false);
     });
   });
 
diff --git a/spec/frontend/ide/stores/mutations_spec.js b/spec/frontend/ide/stores/mutations_spec.js
index 4602a0837e0a9..4117f2648bd61 100644
--- a/spec/frontend/ide/stores/mutations_spec.js
+++ b/spec/frontend/ide/stores/mutations_spec.js
@@ -30,13 +30,13 @@ describe('Multi-file store mutations', () => {
         entry,
       });
 
-      expect(entry.loading).toBeTruthy();
+      expect(entry.loading).toBe(true);
 
       mutations.TOGGLE_LOADING(localState, {
         entry,
       });
 
-      expect(entry.loading).toBeFalsy();
+      expect(entry.loading).toBe(false);
     });
 
     it('toggles loading of entry and sets specific value', () => {
@@ -44,14 +44,14 @@ describe('Multi-file store mutations', () => {
         entry,
       });
 
-      expect(entry.loading).toBeTruthy();
+      expect(entry.loading).toBe(true);
 
       mutations.TOGGLE_LOADING(localState, {
         entry,
         forceValue: true,
       });
 
-      expect(entry.loading).toBeTruthy();
+      expect(entry.loading).toBe(true);
     });
   });
 
diff --git a/spec/frontend/smart_interval_spec.js b/spec/frontend/smart_interval_spec.js
index 5dda097ae6ab2..64928fc4ae9ee 100644
--- a/spec/frontend/smart_interval_spec.js
+++ b/spec/frontend/smart_interval_spec.js
@@ -109,7 +109,7 @@ describe('SmartInterval', () => {
       return waitForPromises().then(() => {
         const { intervalId } = interval.state;
 
-        expect(intervalId).toBeTruthy();
+        expect(intervalId).not.toBeUndefined();
       });
     });
   });
@@ -130,7 +130,7 @@ describe('SmartInterval', () => {
       jest.runOnlyPendingTimers();
 
       return waitForPromises().then(() => {
-        expect(interval.state.intervalId).toBeTruthy();
+        expect(interval.state.intervalId).not.toBeUndefined();
 
         // simulates triggering of visibilitychange event
         interval.onVisibilityChange({ target: { visibilityState: 'hidden' } });
@@ -148,16 +148,16 @@ describe('SmartInterval', () => {
       jest.runOnlyPendingTimers();
 
       return waitForPromises().then(() => {
-        expect(interval.state.intervalId).toBeTruthy();
+        expect(interval.state.intervalId).not.toBeUndefined();
         expect(
           interval.getCurrentInterval() >= DEFAULT_STARTING_INTERVAL &&
             interval.getCurrentInterval() <= DEFAULT_MAX_INTERVAL,
-        ).toBeTruthy();
+        ).toBe(true);
 
         // simulates triggering of visibilitychange event
         interval.onVisibilityChange({ target: { visibilityState: 'hidden' } });
 
-        expect(interval.state.intervalId).toBeTruthy();
+        expect(interval.state.intervalId).not.toBeUndefined();
         expect(interval.getCurrentInterval()).toBe(HIDDEN_INTERVAL);
       });
     });
@@ -166,7 +166,7 @@ describe('SmartInterval', () => {
       jest.runOnlyPendingTimers();
 
       return waitForPromises().then(() => {
-        expect(interval.state.intervalId).toBeTruthy();
+        expect(interval.state.intervalId).not.toBeUndefined();
 
         // simulates triggering of visibilitychange event
         interval.onVisibilityChange({ target: { visibilityState: 'hidden' } });
@@ -176,7 +176,7 @@ describe('SmartInterval', () => {
         // simulates triggering of visibilitychange event
         interval.onVisibilityChange({ target: { visibilityState: 'visible' } });
 
-        expect(interval.state.intervalId).toBeTruthy();
+        expect(interval.state.intervalId).not.toBeUndefined();
       });
     });
 
@@ -194,7 +194,7 @@ describe('SmartInterval', () => {
     it('should execute callback before first interval', () => {
       interval = createDefaultSmartInterval({ immediateExecution: true });
 
-      expect(interval.cfg.immediateExecution).toBeFalsy();
+      expect(interval.cfg.immediateExecution).toBe(false);
     });
   });
 });
diff --git a/spec/frontend/user_popovers_spec.js b/spec/frontend/user_popovers_spec.js
index 0530569c9dfcc..8ce071c075f0f 100644
--- a/spec/frontend/user_popovers_spec.js
+++ b/spec/frontend/user_popovers_spec.js
@@ -188,8 +188,8 @@ describe('User Popovers', () => {
       });
 
       it('removes title attribute from user links', () => {
-        expect(userLink.getAttribute('title')).toBeFalsy();
-        expect(userLink.dataset.originalTitle).toBeFalsy();
+        expect(userLink.getAttribute('title')).toBe('');
+        expect(userLink.dataset.originalTitle).toBe('');
       });
 
       it('fetches user info and status from the user cache', () => {
-- 
GitLab