2018-11-27 05:05:25 -05:00
|
|
|
import blobBundle from '~/blob_edit/blob_bundle';
|
|
|
|
import $ from 'jquery';
|
|
|
|
|
2018-12-14 12:56:25 -05:00
|
|
|
describe('BlobBundle', () => {
|
2018-11-27 05:05:25 -05:00
|
|
|
beforeEach(() => {
|
2018-12-14 12:56:25 -05:00
|
|
|
spyOnDependency(blobBundle, 'EditBlob').and.stub();
|
2018-11-27 05:05:25 -05:00
|
|
|
setFixtures(`
|
2018-12-14 12:56:25 -05:00
|
|
|
<div class="js-edit-blob-form" data-blob-filename="blah">
|
2018-11-27 05:05:25 -05:00
|
|
|
<button class="js-commit-button"></button>
|
2018-12-13 16:27:23 -05:00
|
|
|
<a class="btn btn-cancel" href="#"></a>
|
2018-11-27 05:05:25 -05:00
|
|
|
</div>`);
|
|
|
|
blobBundle();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('sets the window beforeunload listener to a function returning a string', () => {
|
|
|
|
expect(window.onbeforeunload()).toBe('');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('removes beforeunload listener if commit button is clicked', () => {
|
|
|
|
$('.js-commit-button').click();
|
|
|
|
|
|
|
|
expect(window.onbeforeunload).toBeNull();
|
|
|
|
});
|
2018-12-13 16:27:23 -05:00
|
|
|
|
|
|
|
it('removes beforeunload listener when cancel link is clicked', () => {
|
|
|
|
$('.btn.btn-cancel').click();
|
|
|
|
|
|
|
|
expect(window.onbeforeunload).toBeNull();
|
|
|
|
});
|
2018-11-27 05:05:25 -05:00
|
|
|
});
|