diff options
author | Phil Hughes <me@iamphill.com> | 2018-01-31 09:27:30 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-01-31 09:27:30 +0000 |
commit | f165bda4ae2a92528e6f4da25825c1e441094c54 (patch) | |
tree | 3c68c58a56cdc390dc75e83a786200cf0e3fa662 | |
parent | 58eb3c55c9d15bd604b926ffeae9401f0b70c53c (diff) | |
download | gitlab-ce-f165bda4ae2a92528e6f4da25825c1e441094c54.tar.gz |
fixed failing specs
-rw-r--r-- | app/assets/javascripts/labels_select.js | 12 | ||||
-rw-r--r-- | app/assets/javascripts/merge_request_tabs.js | 2 | ||||
-rw-r--r-- | spec/javascripts/issue_spec.js | 4 | ||||
-rw-r--r-- | spec/javascripts/job_spec.js | 8 | ||||
-rw-r--r-- | spec/javascripts/labels_issue_sidebar_spec.js | 43 | ||||
-rw-r--r-- | spec/javascripts/merge_request_tabs_spec.js | 8 |
6 files changed, 43 insertions, 34 deletions
diff --git a/app/assets/javascripts/labels_select.js b/app/assets/javascripts/labels_select.js index 06b8333db27..5ecf81ad11d 100644 --- a/app/assets/javascripts/labels_select.js +++ b/app/assets/javascripts/labels_select.js @@ -102,28 +102,28 @@ export default class LabelsSelect { } $value.removeAttr('style').html(template); $sidebarCollapsedValue.text(labelCount); - + if (data.labels.length) { labelTitles = data.labels.map(function(label) { return label.title; }); - + if (labelTitles.length > 5) { labelTitles = labelTitles.slice(0, 5); labelTitles.push('and ' + (data.labels.length - 5) + ' more'); } - + labelTooltipTitle = labelTitles.join(', '); } else { labelTooltipTitle = ''; $sidebarLabelTooltip.tooltip('destroy'); } - + $sidebarLabelTooltip .attr('title', labelTooltipTitle) .tooltip('fixTitle'); - + $('.has-tooltip', $value).tooltip({ container: 'body' }); @@ -168,7 +168,7 @@ export default class LabelsSelect { data = extraData.concat(data); } } - + callback(data); if (showMenuAbove) { $dropdown.data('glDropdown').positionMenuAbove(); diff --git a/app/assets/javascripts/merge_request_tabs.js b/app/assets/javascripts/merge_request_tabs.js index f69506a0471..6151e90aa04 100644 --- a/app/assets/javascripts/merge_request_tabs.js +++ b/app/assets/javascripts/merge_request_tabs.js @@ -246,7 +246,7 @@ export default class MergeRequestTabs { return; } - this.toggleLoading(true) + this.toggleLoading(true); axios.get(`${source}.json`) .then(({ data }) => { diff --git a/spec/javascripts/issue_spec.js b/spec/javascripts/issue_spec.js index 2da7cede510..7eaaa0ff027 100644 --- a/spec/javascripts/issue_spec.js +++ b/spec/javascripts/issue_spec.js @@ -1,5 +1,5 @@ /* eslint-disable space-before-function-paren, one-var, one-var-declaration-per-line, no-use-before-define, comma-dangle, max-len */ -import MockAdaptor from 'axios-mock-adapter'; +import MockAdapter from 'axios-mock-adapter'; import axios from '~/lib/utils/axios_utils'; import Issue from '~/issue'; import '~/lib/utils/text_utility'; @@ -138,7 +138,7 @@ describe('Issue', function() { this.issueStateDeferred = new jQuery.Deferred(); this.canCreateBranchDeferred = new jQuery.Deferred(); - mock = new MockAdaptor(axios); + mock = new MockAdapter(axios); spyOn(jQuery, 'ajax').and.callFake(ajaxSpy.bind(this)); }); diff --git a/spec/javascripts/job_spec.js b/spec/javascripts/job_spec.js index c3d8d821ac4..03b58e9c1d0 100644 --- a/spec/javascripts/job_spec.js +++ b/spec/javascripts/job_spec.js @@ -1,4 +1,4 @@ -import MockAdaptor from 'axios-mock-adapter'; +import MockAdapter from 'axios-mock-adapter'; import axios from '~/lib/utils/axios_utils'; import { numberToHumanSize } from '~/lib/utils/number_utils'; import * as urlUtils from '~/lib/utils/url_utility'; @@ -22,11 +22,9 @@ describe('Job', () => { spyOn(urlUtils, 'visitUrl'); - mock = new MockAdaptor(axios); + mock = new MockAdapter(axios); - mock.onGet(new RegExp(`${JOB_URL}/trace.json?(.*)`)).reply(() => { - return [200, response]; - }); + mock.onGet(new RegExp(`${JOB_URL}/trace.json?(.*)`)).reply(() => [200, response]); }); afterEach(() => { diff --git a/spec/javascripts/labels_issue_sidebar_spec.js b/spec/javascripts/labels_issue_sidebar_spec.js index a197b35f6fb..7d992f62f64 100644 --- a/spec/javascripts/labels_issue_sidebar_spec.js +++ b/spec/javascripts/labels_issue_sidebar_spec.js @@ -1,4 +1,6 @@ /* eslint-disable no-new */ +import MockAdapter from 'axios-mock-adapter'; +import axios from '~/lib/utils/axios_utils'; import IssuableContext from '~/issuable_context'; import LabelsSelect from '~/labels_select'; @@ -10,35 +12,44 @@ import '~/users_select'; (() => { let saveLabelCount = 0; + let mock; + describe('Issue dropdown sidebar', () => { preloadFixtures('static/issue_sidebar_label.html.raw'); beforeEach(() => { loadFixtures('static/issue_sidebar_label.html.raw'); + + mock = new MockAdapter(axios); + new IssuableContext('{"id":1,"name":"Administrator","username":"root"}'); new LabelsSelect(); - spyOn(jQuery, 'ajax').and.callFake((req) => { - const d = $.Deferred(); - let LABELS_DATA = []; + mock.onGet('/root/test/labels.json').reply(() => { + const labels = Array(10).fill().map((_, i) => ({ + id: i, + title: `test ${i}`, + color: '#5CB85C', + })); - if (req.url === '/root/test/labels.json') { - for (let i = 0; i < 10; i += 1) { - LABELS_DATA.push({ id: i, title: `test ${i}`, color: '#5CB85C' }); - } - } else if (req.url === '/root/test/issues/2.json') { - const tmp = []; - for (let i = 0; i < saveLabelCount; i += 1) { - tmp.push({ id: i, title: `test ${i}`, color: '#5CB85C' }); - } - LABELS_DATA = { labels: tmp }; - } + return [200, labels]; + }); + + mock.onPut('/root/test/issues/2.json').reply(() => { + const labels = Array(saveLabelCount).fill().map((_, i) => ({ + id: i, + title: `test ${i}`, + color: '#5CB85C', + })); - d.resolve(LABELS_DATA); - return d.promise(); + return [200, { labels }]; }); }); + afterEach(() => { + mock.restore(); + }); + it('changes collapsed tooltip when changing labels when less than 5', (done) => { saveLabelCount = 5; $('.edit-link').get(0).click(); diff --git a/spec/javascripts/merge_request_tabs_spec.js b/spec/javascripts/merge_request_tabs_spec.js index 116c4e8f0e4..fda24db98b4 100644 --- a/spec/javascripts/merge_request_tabs_spec.js +++ b/spec/javascripts/merge_request_tabs_spec.js @@ -1,5 +1,5 @@ /* eslint-disable no-var, comma-dangle, object-shorthand */ -import MockAdaptor from 'axios-mock-adapter'; +import MockAdapter from 'axios-mock-adapter'; import axios from '~/lib/utils/axios_utils'; import * as urlUtils from '~/lib/utils/url_utility'; import MergeRequestTabs from '~/merge_request_tabs'; @@ -218,7 +218,7 @@ import 'vendor/jquery.scrollTo'; let mock; beforeEach(function () { - mock = new MockAdaptor(axios); + mock = new MockAdapter(axios); mock.onGet(/(.*)\/diffs\.json/).reply(200, { data: { html: '' }, }); @@ -344,7 +344,7 @@ import 'vendor/jquery.scrollTo'; .attr('href') .replace('#', ''); - mock = new MockAdaptor(axios); + mock = new MockAdapter(axios); mock.onGet(/(.*)\/diffs\.json/).reply(200, diffsResponse); }); @@ -410,7 +410,7 @@ import 'vendor/jquery.scrollTo'; .attr('href') .replace('#', ''); - mock = new MockAdaptor(axios); + mock = new MockAdapter(axios); mock.onGet(/(.*)\/diffs\.json/).reply(200, diffsResponse); }); |