提交 ae62fc05 编写于 作者: A Alfredo Sumaran

Fixes failing spec

上级 0dd3ce62
......@@ -90,6 +90,7 @@ import './flash';
.on('click', this.clickTab);
}
// Used in tests
unbindEvents() {
$(document)
.off('shown.bs.tab', '.merge-request-tabs a[data-toggle="tab"]', this.tabShown)
......@@ -103,6 +104,7 @@ import './flash';
if (this.commitPipelinesTable) {
document.querySelector('#commit-pipeline-table-view')
.removeChild(this.commitPipelinesTable.$el);
this.commitPipelinesTable.$destroy();
}
}
......
......@@ -39,7 +39,8 @@ require('vendor/jquery.scrollTo');
});
afterEach(function () {
this.class.destroy();
this.class.unbindEvents();
this.class.destroyPipelinesView();
});
describe('#activateTab', function () {
......@@ -65,6 +66,7 @@ require('vendor/jquery.scrollTo');
expect($('#diffs')).toHaveClass('active');
});
});
describe('#opensInNewTab', function () {
var tabUrl;
var windowTarget = '_blank';
......@@ -116,6 +118,7 @@ require('vendor/jquery.scrollTo');
stopImmediatePropagation: function () {}
});
});
it('opens page tab in a new browser tab with Cmd+Click - Mac', function () {
spyOn(window, 'open').and.callFake(function (url, name) {
expect(url).toEqual(tabUrl);
......@@ -129,6 +132,7 @@ require('vendor/jquery.scrollTo');
stopImmediatePropagation: function () {}
});
});
it('opens page tab in a new browser tab with Middle-click - Mac/PC', function () {
spyOn(window, 'open').and.callFake(function (url, name) {
expect(url).toEqual(tabUrl);
......@@ -149,6 +153,7 @@ require('vendor/jquery.scrollTo');
spyOn($, 'ajax').and.callFake(function () {});
this.subject = this.class.setCurrentAction;
});
it('changes from commits', function () {
setLocation({
pathname: '/foo/bar/merge_requests/1/commits'
......@@ -156,13 +161,16 @@ require('vendor/jquery.scrollTo');
expect(this.subject('notes')).toBe('/foo/bar/merge_requests/1');
expect(this.subject('diffs')).toBe('/foo/bar/merge_requests/1/diffs');
});
it('changes from diffs', function () {
setLocation({
pathname: '/foo/bar/merge_requests/1/diffs'
});
expect(this.subject('notes')).toBe('/foo/bar/merge_requests/1');
expect(this.subject('commits')).toBe('/foo/bar/merge_requests/1/commits');
});
it('changes from diffs.html', function () {
setLocation({
pathname: '/foo/bar/merge_requests/1/diffs.html'
......@@ -170,6 +178,7 @@ require('vendor/jquery.scrollTo');
expect(this.subject('notes')).toBe('/foo/bar/merge_requests/1');
expect(this.subject('commits')).toBe('/foo/bar/merge_requests/1/commits');
});
it('changes from notes', function () {
setLocation({
pathname: '/foo/bar/merge_requests/1'
......@@ -177,6 +186,7 @@ require('vendor/jquery.scrollTo');
expect(this.subject('diffs')).toBe('/foo/bar/merge_requests/1/diffs');
expect(this.subject('commits')).toBe('/foo/bar/merge_requests/1/commits');
});
it('includes search parameters and hash string', function () {
setLocation({
pathname: '/foo/bar/merge_requests/1/diffs',
......@@ -185,6 +195,7 @@ require('vendor/jquery.scrollTo');
});
expect(this.subject('show')).toBe('/foo/bar/merge_requests/1?view=parallel#L15-35');
});
it('replaces the current history state', function () {
var newState;
setLocation({
......@@ -197,6 +208,7 @@ require('vendor/jquery.scrollTo');
}, document.title, newState);
}
});
it('treats "show" like "notes"', function () {
setLocation({
pathname: '/foo/bar/merge_requests/1/commits'
......@@ -207,6 +219,7 @@ require('vendor/jquery.scrollTo');
describe('#tabShown', () => {
beforeEach(function () {
spyOn($, 'ajax').and.callFake(function () {});
loadFixtures('merge_requests/merge_request_with_task_list.html.raw');
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册