Commit cbfc97b1 authored by Phil Hughes's avatar Phil Hughes

karma spec fixes

parent 6c97107d
<script> <script>
import Visibility from 'visibilityjs'; import Visibility from 'visibilityjs';
import Flash from '../../flash';
import Poll from '../../lib/utils/poll'; import Poll from '../../lib/utils/poll';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import Service from '../services/index'; import Service from '../services/index';
...@@ -153,7 +152,7 @@ export default { ...@@ -153,7 +152,7 @@ export default {
}) })
.catch(() => { .catch(() => {
eventHub.$emit('close.form'); eventHub.$emit('close.form');
return new Flash('Error updating issue'); window.Flash('Error updating issue');
}); });
}, },
deleteIssuable() { deleteIssuable() {
...@@ -167,7 +166,7 @@ export default { ...@@ -167,7 +166,7 @@ export default {
}) })
.catch(() => { .catch(() => {
eventHub.$emit('close.form'); eventHub.$emit('close.form');
return new Flash('Error deleting issue'); window.Flash('Error deleting issue');
}); });
}, },
}, },
......
import axios from 'axios'; import axios from 'axios';
import Flash from '../../flash';
import Store from '../stores/repo_store'; import Store from '../stores/repo_store';
import Api from '../../api'; import Api from '../../api';
import Helper from '../helpers/repo_helper'; import Helper from '../helpers/repo_helper';
...@@ -72,9 +71,9 @@ const RepoService = { ...@@ -72,9 +71,9 @@ const RepoService = {
commitFlash(data) { commitFlash(data) {
if (data.short_id && data.stats) { if (data.short_id && data.stats) {
Flash(`Your changes have been committed. Commit ${data.short_id} with ${data.stats.additions} additions, ${data.stats.deletions} deletions.`, 'notice'); window.Flash(`Your changes have been committed. Commit ${data.short_id} with ${data.stats.additions} additions, ${data.stats.deletions} deletions.`, 'notice');
} else { } else {
Flash(data.message); window.Flash(data.message);
} }
}, },
}; };
......
import Flash from '../../flash';
function isValidProjectId(id) { function isValidProjectId(id) {
return id > 0; return id > 0;
} }
...@@ -38,7 +36,7 @@ class SidebarMoveIssue { ...@@ -38,7 +36,7 @@ class SidebarMoveIssue {
data: (searchTerm, callback) => { data: (searchTerm, callback) => {
this.mediator.fetchAutocompleteProjects(searchTerm) this.mediator.fetchAutocompleteProjects(searchTerm)
.then(callback) .then(callback)
.catch(() => new Flash('An error occurred while fetching projects autocomplete.')); .catch(() => new window.Flash('An error occurred while fetching projects autocomplete.'));
}, },
renderRow: project => ` renderRow: project => `
<li> <li>
...@@ -73,7 +71,7 @@ class SidebarMoveIssue { ...@@ -73,7 +71,7 @@ class SidebarMoveIssue {
this.mediator.moveIssue() this.mediator.moveIssue()
.catch(() => { .catch(() => {
Flash('An error occurred while moving the issue.'); window.Flash('An error occurred while moving the issue.');
this.$confirmButton this.$confirmButton
.enable() .enable()
.removeClass('is-loading'); .removeClass('is-loading');
......
import Flash from '../../../flash';
import statusIcon from '../mr_widget_status_icon'; import statusIcon from '../mr_widget_status_icon';
import tooltip from '../../../vue_shared/directives/tooltip'; import tooltip from '../../../vue_shared/directives/tooltip';
import eventHub from '../../event_hub'; import eventHub from '../../event_hub';
...@@ -27,12 +26,12 @@ export default { ...@@ -27,12 +26,12 @@ export default {
.then(res => res.json()) .then(res => res.json())
.then((res) => { .then((res) => {
eventHub.$emit('UpdateWidgetData', res); eventHub.$emit('UpdateWidgetData', res);
new Flash('The merge request can now be merged.', 'notice'); // eslint-disable-line new window.Flash('The merge request can now be merged.', 'notice'); // eslint-disable-line
$('.merge-request .detail-page-description .title').text(this.mr.title); $('.merge-request .detail-page-description .title').text(this.mr.title);
}) })
.catch(() => { .catch(() => {
this.isMakingRequest = false; this.isMakingRequest = false;
new Flash('Something went wrong. Please try again.'); // eslint-disable-line new window.Flash('Something went wrong. Please try again.'); // eslint-disable-line
}); });
}, },
}, },
......
...@@ -138,9 +138,9 @@ describe('IntegrationSettingsForm', () => { ...@@ -138,9 +138,9 @@ describe('IntegrationSettingsForm', () => {
deferred.resolve({ error: true, message: errorMessage, service_response: 'some error' }); deferred.resolve({ error: true, message: errorMessage, service_response: 'some error' });
const $flashContainer = $('.flash-container'); const $flashContainer = $('.flash-container');
expect($flashContainer.find('.flash-text').text()).toEqual('Test failed. some error'); expect($flashContainer.find('.flash-text').text().trim()).toEqual('Test failed. some error');
expect($flashContainer.find('.flash-action')).toBeDefined(); expect($flashContainer.find('.flash-action')).toBeDefined();
expect($flashContainer.find('.flash-action').text()).toEqual('Save anyway'); expect($flashContainer.find('.flash-action').text().trim()).toEqual('Save anyway');
}); });
it('should submit form if ajax request responds without any error in test', () => { it('should submit form if ajax request responds without any error in test', () => {
...@@ -168,7 +168,7 @@ describe('IntegrationSettingsForm', () => { ...@@ -168,7 +168,7 @@ describe('IntegrationSettingsForm', () => {
expect($flashAction).toBeDefined(); expect($flashAction).toBeDefined();
spyOn(integrationSettingsForm.$form, 'submit'); spyOn(integrationSettingsForm.$form, 'submit');
$flashAction.trigger('click'); $flashAction.get(0).click();
expect(integrationSettingsForm.$form.submit).toHaveBeenCalled(); expect(integrationSettingsForm.$form.submit).toHaveBeenCalled();
}); });
......
...@@ -815,7 +815,7 @@ import '~/notes'; ...@@ -815,7 +815,7 @@ import '~/notes';
}); });
it('shows a flash message', () => { it('shows a flash message', () => {
this.notes.addFlash('Error message', FLASH_TYPE_ALERT, this.notes.parentTimeline); this.notes.addFlash('Error message', FLASH_TYPE_ALERT, this.notes.parentTimeline.get(0));
expect($('.flash-alert').is(':visible')).toBeTruthy(); expect($('.flash-alert').is(':visible')).toBeTruthy();
}); });
...@@ -828,7 +828,7 @@ import '~/notes'; ...@@ -828,7 +828,7 @@ import '~/notes';
}); });
it('hides visible flash message', () => { it('hides visible flash message', () => {
this.notes.addFlash('Error message 1', FLASH_TYPE_ALERT, this.notes.parentTimeline); this.notes.addFlash('Error message 1', FLASH_TYPE_ALERT, this.notes.parentTimeline.get(0));
this.notes.clearFlash(); this.notes.clearFlash();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment