diff options
author | Mike Greiling <mike@pixelcog.com> | 2018-10-11 21:55:03 +0000 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2018-10-11 21:55:03 +0000 |
commit | da4f77957ccff7cdf22110ef56a4286bbc5a7749 (patch) | |
tree | d1f1998e69394ec629da29f7a3e3974c460e047d /spec/javascripts | |
parent | db85dbbf5eebbfef2d7497cff5ff1a7e967ab1bd (diff) | |
parent | db4c1f665fb51c64ffb1917503cc6e5b2dd00be8 (diff) | |
download | gitlab-ce-da4f77957ccff7cdf22110ef56a4286bbc5a7749.tar.gz |
Merge branch '51712-prefer-jasmine-matcher' into 'master'
4. enable jasmine/prefer-jasmine-matcher
See merge request gitlab-org/gitlab-ce!22236
Diffstat (limited to 'spec/javascripts')
18 files changed, 42 insertions, 45 deletions
diff --git a/spec/javascripts/.eslintrc.yml b/spec/javascripts/.eslintrc.yml index a7bf2baba9e..1448849a0b7 100644 --- a/spec/javascripts/.eslintrc.yml +++ b/spec/javascripts/.eslintrc.yml @@ -38,5 +38,4 @@ rules: # Temporarily disabled to facilitate an upgrade to eslint-plugin-jasmine jasmine/new-line-before-expect: off jasmine/no-promise-without-done-fail: off - jasmine/prefer-jasmine-matcher: off jasmine/prefer-toHaveBeenCalledWith: off diff --git a/spec/javascripts/datetime_utility_spec.js b/spec/javascripts/datetime_utility_spec.js index 6c3e73f134e..24e4871ce44 100644 --- a/spec/javascripts/datetime_utility_spec.js +++ b/spec/javascripts/datetime_utility_spec.js @@ -158,9 +158,9 @@ describe('getTimeframeWindowFrom', () => { const timeframe = datetimeUtility.getTimeframeWindowFrom(startDate, 5); expect(timeframe.length).toBe(5); timeframe.forEach((timeframeItem, index) => { - expect(timeframeItem.getFullYear() === mockTimeframe[index].getFullYear()).toBe(true); - expect(timeframeItem.getMonth() === mockTimeframe[index].getMonth()).toBe(true); - expect(timeframeItem.getDate() === mockTimeframe[index].getDate()).toBeTruthy(); + expect(timeframeItem.getFullYear()).toBe(mockTimeframe[index].getFullYear()); + expect(timeframeItem.getMonth()).toBe(mockTimeframe[index].getMonth()); + expect(timeframeItem.getDate()).toBe(mockTimeframe[index].getDate()); }); }); }); diff --git a/spec/javascripts/diffs/components/diff_file_spec.js b/spec/javascripts/diffs/components/diff_file_spec.js index 13859f43e98..b8d4b31ee04 100644 --- a/spec/javascripts/diffs/components/diff_file_spec.js +++ b/spec/javascripts/diffs/components/diff_file_spec.js @@ -24,14 +24,14 @@ describe('DiffFile', () => { expect(el.querySelectorAll('.diff-content.hidden').length).toEqual(0); expect(el.querySelector('.js-file-title')).toBeDefined(); - expect(el.querySelector('.file-title-name').innerText.indexOf(filePath) > -1).toEqual(true); + expect(el.querySelector('.file-title-name').innerText.indexOf(filePath)).toBeGreaterThan(-1); expect(el.querySelector('.js-syntax-highlight')).toBeDefined(); expect(vm.file.renderIt).toEqual(false); vm.file.renderIt = true; vm.$nextTick(() => { - expect(el.querySelectorAll('.line_content').length > 5).toEqual(true); + expect(el.querySelectorAll('.line_content').length).toBeGreaterThan(5); }); }); @@ -98,9 +98,7 @@ describe('DiffFile', () => { 'This source diff could not be displayed because it is too large', ); expect(vm.$el.querySelector('.js-too-large-diff')).toBeDefined(); - expect(vm.$el.querySelector('.js-too-large-diff a').href.indexOf(BLOB_LINK) > -1).toEqual( - true, - ); + expect(vm.$el.querySelector('.js-too-large-diff a').href.indexOf(BLOB_LINK)).toBeGreaterThan(-1); done(); }); diff --git a/spec/javascripts/diffs/components/diff_line_gutter_content_spec.js b/spec/javascripts/diffs/components/diff_line_gutter_content_spec.js index 663c0680845..f36454cc23e 100644 --- a/spec/javascripts/diffs/components/diff_line_gutter_content_spec.js +++ b/spec/javascripts/diffs/components/diff_line_gutter_content_spec.js @@ -94,7 +94,7 @@ describe('DiffLineGutterContent', () => { const component = createComponent({ lineNumber, lineCode }); const link = component.$el.querySelector('a'); - expect(link.href.indexOf(`#${lineCode}`) > -1).toEqual(true); + expect(link.href.indexOf(`#${lineCode}`)).toBeGreaterThan(-1); expect(link.dataset.linenumber).toEqual(lineNumber.toString()); }); diff --git a/spec/javascripts/diffs/components/inline_diff_view_spec.js b/spec/javascripts/diffs/components/inline_diff_view_spec.js index b02328dd359..705558e860b 100644 --- a/spec/javascripts/diffs/components/inline_diff_view_spec.js +++ b/spec/javascripts/diffs/components/inline_diff_view_spec.js @@ -27,7 +27,7 @@ describe('InlineDiffView', () => { expect(el.querySelectorAll('tr.line_holder').length).toEqual(6); expect(el.querySelectorAll('tr.line_holder.new').length).toEqual(2); expect(el.querySelectorAll('tr.line_holder.match').length).toEqual(1); - expect(el.textContent.indexOf('Bad dates') > -1).toEqual(true); + expect(el.textContent.indexOf('Bad dates')).toBeGreaterThan(-1); }); it('should render discussions', done => { @@ -37,7 +37,7 @@ describe('InlineDiffView', () => { Vue.nextTick(() => { expect(el.querySelectorAll('.notes_holder').length).toEqual(1); expect(el.querySelectorAll('.notes_holder .note-discussion li').length).toEqual(5); - expect(el.innerText.indexOf('comment 5') > -1).toEqual(true); + expect(el.innerText.indexOf('comment 5')).toBeGreaterThan(-1); component.$store.dispatch('setInitialNotes', []); done(); diff --git a/spec/javascripts/filtered_search/dropdown_utils_spec.js b/spec/javascripts/filtered_search/dropdown_utils_spec.js index 68bbbf838da..3dc8089cd83 100644 --- a/spec/javascripts/filtered_search/dropdown_utils_spec.js +++ b/spec/javascripts/filtered_search/dropdown_utils_spec.js @@ -237,7 +237,7 @@ describe('Dropdown Utils', () => { it('should not linear-gradient more than 4 colors', () => { const gradient = DropdownUtils.duplicateLabelColor(['#FFFFFF', '#000000', '#333333', '#DDDDDD', '#EEEEEE']); - expect(gradient.indexOf('#EEEEEE') === -1).toEqual(true); + expect(gradient.indexOf('#EEEEEE')).toBe(-1); }); }); diff --git a/spec/javascripts/filtered_search/filtered_search_token_keys_spec.js b/spec/javascripts/filtered_search/filtered_search_token_keys_spec.js index ab0ab72720e..cf7789a1d57 100644 --- a/spec/javascripts/filtered_search/filtered_search_token_keys_spec.js +++ b/spec/javascripts/filtered_search/filtered_search_token_keys_spec.js @@ -19,7 +19,7 @@ describe('Filtered Search Token Keys', () => { describe('get', () => { it('should return tokenKeys', () => { - expect(new FilteredSearchTokenKeys().get() !== null).toBe(true); + expect(new FilteredSearchTokenKeys().get()).not.toBeNull(); }); it('should return tokenKeys as an array', () => { @@ -40,7 +40,7 @@ describe('Filtered Search Token Keys', () => { describe('getConditions', () => { it('should return conditions', () => { - expect(new FilteredSearchTokenKeys().getConditions() !== null).toBe(true); + expect(new FilteredSearchTokenKeys().getConditions()).not.toBeNull(); }); it('should return conditions as an array', () => { @@ -51,7 +51,7 @@ describe('Filtered Search Token Keys', () => { describe('searchByKey', () => { it('should return null when key not found', () => { const tokenKey = new FilteredSearchTokenKeys(tokenKeys).searchByKey('notakey'); - expect(tokenKey === null).toBe(true); + expect(tokenKey).toBeNull(); }); it('should return tokenKey when found by key', () => { @@ -63,7 +63,7 @@ describe('Filtered Search Token Keys', () => { describe('searchBySymbol', () => { it('should return null when symbol not found', () => { const tokenKey = new FilteredSearchTokenKeys(tokenKeys).searchBySymbol('notasymbol'); - expect(tokenKey === null).toBe(true); + expect(tokenKey).toBeNull(); }); it('should return tokenKey when found by symbol', () => { @@ -75,7 +75,7 @@ describe('Filtered Search Token Keys', () => { describe('searchByKeyParam', () => { it('should return null when key param not found', () => { const tokenKey = new FilteredSearchTokenKeys(tokenKeys).searchByKeyParam('notakeyparam'); - expect(tokenKey === null).toBe(true); + expect(tokenKey).toBeNull(); }); it('should return tokenKey when found by key param', () => { @@ -92,7 +92,7 @@ describe('Filtered Search Token Keys', () => { describe('searchByConditionUrl', () => { it('should return null when condition url not found', () => { const condition = new FilteredSearchTokenKeys([], [], conditions).searchByConditionUrl(null); - expect(condition === null).toBe(true); + expect(condition).toBeNull(); }); it('should return condition when found by url', () => { @@ -106,7 +106,7 @@ describe('Filtered Search Token Keys', () => { it('should return null when condition tokenKey and value not found', () => { const condition = new FilteredSearchTokenKeys([], [], conditions) .searchByConditionKeyValue(null, null); - expect(condition === null).toBe(true); + expect(condition).toBeNull(); }); it('should return condition when found by tokenKey and value', () => { diff --git a/spec/javascripts/gl_dropdown_spec.js b/spec/javascripts/gl_dropdown_spec.js index 25b819543da..62c87642184 100644 --- a/spec/javascripts/gl_dropdown_spec.js +++ b/spec/javascripts/gl_dropdown_spec.js @@ -168,9 +168,9 @@ describe('glDropdown', function describeDropdown() { it('should show loading indicator while search results are being fetched by backend', () => { const dropdownMenu = document.querySelector('.dropdown-menu'); - expect(dropdownMenu.className.indexOf('is-loading') !== -1).toEqual(true); + expect(dropdownMenu.className.indexOf('is-loading')).not.toBe(-1); remoteCallback(); - expect(dropdownMenu.className.indexOf('is-loading') !== -1).toEqual(false); + expect(dropdownMenu.className.indexOf('is-loading')).toBe(-1); }); it('should not focus search input while remote task is not complete', () => { diff --git a/spec/javascripts/groups/components/group_item_spec.js b/spec/javascripts/groups/components/group_item_spec.js index d0cac5efc40..49d4f7efd72 100644 --- a/spec/javascripts/groups/components/group_item_spec.js +++ b/spec/javascripts/groups/components/group_item_spec.js @@ -45,7 +45,7 @@ describe('GroupItemComponent', () => { expect(Object.keys(rowClass).length).toBe(classes.length); Object.keys(rowClass).forEach((className) => { - expect(classes.indexOf(className) > -1).toBeTruthy(); + expect(classes.indexOf(className)).toBeGreaterThan(-1); }); }); }); diff --git a/spec/javascripts/groups/components/groups_spec.js b/spec/javascripts/groups/components/groups_spec.js index 793c4909d89..5af86b55532 100644 --- a/spec/javascripts/groups/components/groups_spec.js +++ b/spec/javascripts/groups/components/groups_spec.js @@ -53,7 +53,7 @@ describe('GroupsComponent', () => { expect(vm.$el.querySelector('.groups-list-tree-container')).toBeDefined(); expect(vm.$el.querySelector('.group-list-tree')).toBeDefined(); expect(vm.$el.querySelector('.gl-pagination')).toBeDefined(); - expect(vm.$el.querySelectorAll('.has-no-search-results').length === 0).toBeTruthy(); + expect(vm.$el.querySelectorAll('.has-no-search-results').length).toBe(0); done(); }); }); diff --git a/spec/javascripts/groups/components/item_stats_spec.js b/spec/javascripts/groups/components/item_stats_spec.js index ee7ee18259e..e6a57495eb1 100644 --- a/spec/javascripts/groups/components/item_stats_spec.js +++ b/spec/javascripts/groups/components/item_stats_spec.js @@ -107,7 +107,7 @@ describe('ItemStatsComponent', () => { const visibilityIconEl = vm.$el.querySelector('.item-visibility'); expect(visibilityIconEl).not.toBe(null); expect(visibilityIconEl.dataset.originalTitle).toBe(vm.visibilityTooltip); - expect(visibilityIconEl.querySelectorAll('svg').length > 0).toBeTruthy(); + expect(visibilityIconEl.querySelectorAll('svg').length).toBeGreaterThan(0); vm.$destroy(); }); @@ -120,10 +120,10 @@ describe('ItemStatsComponent', () => { const vm = createComponent(item); const projectStarIconEl = vm.$el.querySelector('.project-stars'); - expect(projectStarIconEl).not.toBe(null); - expect(projectStarIconEl.querySelectorAll('svg').length > 0).toBeTruthy(); - expect(projectStarIconEl.querySelectorAll('.stat-value').length > 0).toBeTruthy(); - expect(vm.$el.querySelectorAll('.last-updated').length > 0).toBeTruthy(); + expect(projectStarIconEl).not.toBeNull(); + expect(projectStarIconEl.querySelectorAll('svg').length).toBeGreaterThan(0); + expect(projectStarIconEl.querySelectorAll('.stat-value').length).toBeGreaterThan(0); + expect(vm.$el.querySelectorAll('.last-updated').length).toBeGreaterThan(0); vm.$destroy(); }); diff --git a/spec/javascripts/groups/components/item_stats_value_spec.js b/spec/javascripts/groups/components/item_stats_value_spec.js index 5e35ae4d36c..2a995e8efe6 100644 --- a/spec/javascripts/groups/components/item_stats_value_spec.js +++ b/spec/javascripts/groups/components/item_stats_value_spec.js @@ -57,8 +57,8 @@ describe('ItemStatsValueComponent', () => { it('renders component element correctly', () => { expect(vm.$el.classList.contains('number-subgroups')).toBeTruthy(); - expect(vm.$el.querySelectorAll('svg').length > 0).toBeTruthy(); - expect(vm.$el.querySelectorAll('.stat-value').length > 0).toBeTruthy(); + expect(vm.$el.querySelectorAll('svg').length).toBeGreaterThan(0); + expect(vm.$el.querySelectorAll('.stat-value').length).toBeGreaterThan(0); }); it('renders element tooltip correctly', () => { diff --git a/spec/javascripts/groups/store/groups_store_spec.js b/spec/javascripts/groups/store/groups_store_spec.js index d74f38f476e..78caf8f80bf 100644 --- a/spec/javascripts/groups/store/groups_store_spec.js +++ b/spec/javascripts/groups/store/groups_store_spec.js @@ -29,7 +29,7 @@ describe('ProjectsStore', () => { store.setGroups(mockGroups); expect(store.state.groups.length).toBe(mockGroups.length); expect(store.formatGroupItem).toHaveBeenCalledWith(jasmine.any(Object)); - expect(Object.keys(store.state.groups[0]).indexOf('fullName') > -1).toBeTruthy(); + expect(Object.keys(store.state.groups[0]).indexOf('fullName')).toBeGreaterThan(-1); }); }); @@ -41,8 +41,8 @@ describe('ProjectsStore', () => { store.setSearchedGroups(mockSearchedGroups); expect(store.state.groups.length).toBe(mockSearchedGroups.length); expect(store.formatGroupItem).toHaveBeenCalledWith(jasmine.any(Object)); - expect(Object.keys(store.state.groups[0]).indexOf('fullName') > -1).toBeTruthy(); - expect(Object.keys(store.state.groups[0].children[0]).indexOf('fullName') > -1).toBeTruthy(); + expect(Object.keys(store.state.groups[0]).indexOf('fullName')).toBeGreaterThan(-1); + expect(Object.keys(store.state.groups[0].children[0]).indexOf('fullName')).toBeGreaterThan(-1); }); }); @@ -54,7 +54,7 @@ describe('ProjectsStore', () => { store.setGroupChildren(mockParentGroupItem, mockRawChildren); expect(store.formatGroupItem).toHaveBeenCalledWith(jasmine.any(Object)); expect(mockParentGroupItem.children.length).toBe(1); - expect(Object.keys(mockParentGroupItem.children[0]).indexOf('fullName') > -1).toBeTruthy(); + expect(Object.keys(mockParentGroupItem.children[0]).indexOf('fullName')).toBeGreaterThan(-1); expect(mockParentGroupItem.isOpen).toBeTruthy(); expect(mockParentGroupItem.isChildrenLoading).toBeFalsy(); }); @@ -81,14 +81,14 @@ describe('ProjectsStore', () => { store = new GroupsStore(); updatedGroupItem = store.formatGroupItem(mockRawChildren[0]); - expect(Object.keys(updatedGroupItem).indexOf('fullName') > -1).toBeTruthy(); + expect(Object.keys(updatedGroupItem).indexOf('fullName')).toBeGreaterThan(-1); expect(updatedGroupItem.childrenCount).toBe(mockRawChildren[0].children_count); expect(updatedGroupItem.isChildrenLoading).toBe(false); expect(updatedGroupItem.isBeingRemoved).toBe(false); store = new GroupsStore(true); updatedGroupItem = store.formatGroupItem(mockRawChildren[0]); - expect(Object.keys(updatedGroupItem).indexOf('fullName') > -1).toBeTruthy(); + expect(Object.keys(updatedGroupItem).indexOf('fullName')).toBeGreaterThan(-1); expect(updatedGroupItem.childrenCount).toBe(mockRawChildren[0].subgroup_count); }); }); diff --git a/spec/javascripts/image_diff/helpers/comment_indicator_helper_spec.js b/spec/javascripts/image_diff/helpers/comment_indicator_helper_spec.js index a284b981d2a..9d05c6859df 100644 --- a/spec/javascripts/image_diff/helpers/comment_indicator_helper_spec.js +++ b/spec/javascripts/image_diff/helpers/comment_indicator_helper_spec.js @@ -32,7 +32,7 @@ describe('commentIndicatorHelper', () => { expect(svgEl).toBeDefined(); const svgLink = svgEl.querySelector('use').getAttribute('xlink:href'); - expect(svgLink.indexOf('image-comment-dark') !== -1).toEqual(true); + expect(svgLink.indexOf('image-comment-dark')).not.toBe(-1); }); }); }); diff --git a/spec/javascripts/lib/utils/common_utils_spec.js b/spec/javascripts/lib/utils/common_utils_spec.js index 7474f23b8c4..c34622203f7 100644 --- a/spec/javascripts/lib/utils/common_utils_spec.js +++ b/spec/javascripts/lib/utils/common_utils_spec.js @@ -43,7 +43,7 @@ describe('common_utils', () => { it('should remove the question mark from the search params', () => { const paramsArray = commonUtils.urlParamsToArray('?test=thing'); - expect(paramsArray[0][0] !== '?').toBe(true); + expect(paramsArray[0][0]).not.toBe('?'); }); }); diff --git a/spec/javascripts/notes_spec.js b/spec/javascripts/notes_spec.js index faeedae40e9..7bfbca83c77 100644 --- a/spec/javascripts/notes_spec.js +++ b/spec/javascripts/notes_spec.js @@ -538,7 +538,7 @@ import timeoutPromise from './helpers/set_timeout_promise_helper'; mockNotesPost(); $('.js-comment-button').click(); - expect($notesContainer.find('.note.being-posted').length > 0).toEqual(true); + expect($notesContainer.find('.note.being-posted').length).toBeGreaterThan(0); }); it('should remove placeholder note when new comment is done posting', done => { @@ -582,7 +582,7 @@ import timeoutPromise from './helpers/set_timeout_promise_helper'; $('.js-comment-button').click(); setTimeout(() => { - expect($notesContainer.find(`#note_${note.id}`).length > 0).toEqual(true); + expect($notesContainer.find(`#note_${note.id}`).length).toBeGreaterThan(0); done(); }); @@ -776,7 +776,7 @@ import timeoutPromise from './helpers/set_timeout_promise_helper'; $form.find('textarea.js-note-text').val(sampleComment); const { formData, formContent, formAction } = this.notes.getFormData($form); - expect(formData.indexOf(sampleComment) > -1).toBe(true); + expect(formData.indexOf(sampleComment)).toBeGreaterThan(-1); expect(formContent).toEqual(sampleComment); expect(formAction).toEqual($form.attr('action')); }); diff --git a/spec/javascripts/vue_mr_widget/components/mr_widget_memory_usage_spec.js b/spec/javascripts/vue_mr_widget/components/mr_widget_memory_usage_spec.js index 91e81a0675a..305cee94f57 100644 --- a/spec/javascripts/vue_mr_widget/components/mr_widget_memory_usage_spec.js +++ b/spec/javascripts/vue_mr_widget/components/mr_widget_memory_usage_spec.js @@ -137,7 +137,7 @@ describe('MemoryUsage', () => { } = vm; expect(hasMetrics).toBeTruthy(); - expect(memoryMetrics.length > 0).toBeTruthy(); + expect(memoryMetrics.length).toBeGreaterThan(0); expect(deploymentTime).toEqual(deployment_time); expect(memoryFrom).toEqual('9.13'); expect(memoryTo).toEqual('4.28'); diff --git a/spec/javascripts/vue_shared/components/memory_graph_spec.js b/spec/javascripts/vue_shared/components/memory_graph_spec.js index 65d8ed39ade..0982b3e1f38 100644 --- a/spec/javascripts/vue_shared/components/memory_graph_spec.js +++ b/spec/javascripts/vue_shared/components/memory_graph_spec.js @@ -52,8 +52,8 @@ describe('MemoryGraph', () => { it('should show human readable median value based on provided median timestamp', () => { vm.deploymentTime = mockMedian; const formattedMedian = vm.getFormattedMedian; - expect(formattedMedian.indexOf('Deployed') > -1).toBeTruthy(); - expect(formattedMedian.indexOf('ago') > -1).toBeTruthy(); + expect(formattedMedian.indexOf('Deployed')).toBeGreaterThan(-1); + expect(formattedMedian.indexOf('ago')).toBeGreaterThan(-1); }); }); }); |