Commit 958cf02e authored by Tim Zallmann's avatar Tim Zallmann

Fixes for Karma tests

parent 8563499b
...@@ -18,11 +18,11 @@ describe('ParallelDiffView', () => { ...@@ -18,11 +18,11 @@ describe('ParallelDiffView', () => {
}).$mount(); }).$mount();
}); });
describe('computed', () => { describe('assigned', () => {
describe('parallelDiffLines', () => { describe('diffLines', () => {
it('should normalize lines for empty cells', () => { it('should normalize lines for empty cells', () => {
expect(component.parallelDiffLines[0].left.type).toEqual(constants.EMPTY_CELL_TYPE); expect(component.diffLines[0].left.type).toEqual(constants.EMPTY_CELL_TYPE);
expect(component.parallelDiffLines[1].left.type).toEqual(constants.EMPTY_CELL_TYPE); expect(component.diffLines[1].left.type).toEqual(constants.EMPTY_CELL_TYPE);
}); });
}); });
}); });
......
...@@ -190,22 +190,27 @@ describe('Diffs Module Getters', () => { ...@@ -190,22 +190,27 @@ describe('Diffs Module Getters', () => {
beforeEach(() => { beforeEach(() => {
line = {}; line = {};
discussionMock.expanded = true;
line.left = { line.left = {
lineCode: 'ABC', lineCode: 'ABC',
discussions: [discussionMock],
}; };
line.right = { line.right = {
lineCode: 'DEF', lineCode: 'DEF',
discussions: [discussionMock1],
}; };
}); });
it('returns true when discussion is expanded', () => { it('returns true when discussion is expanded', () => {
discussionMock.expanded = true;
expect(getters.shouldRenderParallelCommentRow(localState)(line)).toEqual(true); expect(getters.shouldRenderParallelCommentRow(localState)(line)).toEqual(true);
}); });
it('returns false when no discussion was found', () => { it('returns false when no discussion was found', () => {
line.left.discussions = [];
line.right.discussions = [];
localState.diffLineCommentForms.ABC = false; localState.diffLineCommentForms.ABC = false;
localState.diffLineCommentForms.DEF = false; localState.diffLineCommentForms.DEF = false;
...@@ -220,32 +225,32 @@ describe('Diffs Module Getters', () => { ...@@ -220,32 +225,32 @@ describe('Diffs Module Getters', () => {
}); });
describe('shouldRenderInlineCommentRow', () => { describe('shouldRenderInlineCommentRow', () => {
let line;
beforeEach(() => {
discussionMock.expanded = true;
line = {
lineCode: 'ABC',
discussions: [discussionMock],
};
});
it('returns true when diffLineCommentForms has form', () => { it('returns true when diffLineCommentForms has form', () => {
localState.diffLineCommentForms.ABC = {}; localState.diffLineCommentForms.ABC = {};
expect( expect(getters.shouldRenderInlineCommentRow(localState)(line)).toEqual(true);
getters.shouldRenderInlineCommentRow(localState)({
lineCode: 'ABC',
}),
).toEqual(true);
}); });
it('returns false when no line discussions were found', () => { it('returns false when no line discussions were found', () => {
expect( line.discussions = [];
getters.shouldRenderInlineCommentRow(localState, { expect(getters.shouldRenderInlineCommentRow(localState)(line)).toEqual(false);
singleDiscussionByLineCode: () => [],
})('DEF'),
).toEqual(false);
}); });
it('returns true if all found discussions are expanded', () => { it('returns true if all found discussions are expanded', () => {
discussionMock.expanded = true; discussionMock.expanded = true;
expect( expect(getters.shouldRenderInlineCommentRow(localState)(line)).toEqual(true);
getters.shouldRenderInlineCommentRow(localState, {
singleDiscussionByLineCode: () => [discussionMock],
})('ABC'),
).toEqual(true);
}); });
}); });
......
...@@ -2,10 +2,10 @@ import LazyLoader from '~/lazy_loader'; ...@@ -2,10 +2,10 @@ import LazyLoader from '~/lazy_loader';
let lazyLoader = null; let lazyLoader = null;
describe('LazyLoader', function () { describe('LazyLoader', function() {
preloadFixtures('issues/issue_with_comment.html.raw'); preloadFixtures('issues/issue_with_comment.html.raw');
beforeEach(function () { beforeEach(function() {
loadFixtures('issues/issue_with_comment.html.raw'); loadFixtures('issues/issue_with_comment.html.raw');
lazyLoader = new LazyLoader({ lazyLoader = new LazyLoader({
observerNode: 'body', observerNode: 'body',
...@@ -13,8 +13,8 @@ describe('LazyLoader', function () { ...@@ -13,8 +13,8 @@ describe('LazyLoader', function () {
// Doing everything that happens normally in onload // Doing everything that happens normally in onload
lazyLoader.loadCheck(); lazyLoader.loadCheck();
}); });
describe('behavior', function () { describe('behavior', function() {
it('should copy value from data-src to src for img 1', function (done) { it('should copy value from data-src to src for img 1', function(done) {
const img = document.querySelectorAll('img[data-src]')[0]; const img = document.querySelectorAll('img[data-src]')[0];
const originalDataSrc = img.getAttribute('data-src'); const originalDataSrc = img.getAttribute('data-src');
img.scrollIntoView(); img.scrollIntoView();
...@@ -26,7 +26,7 @@ describe('LazyLoader', function () { ...@@ -26,7 +26,7 @@ describe('LazyLoader', function () {
}, 100); }, 100);
}); });
it('should lazy load dynamically added data-src images', function (done) { it('should lazy load dynamically added data-src images', function(done) {
const newImg = document.createElement('img'); const newImg = document.createElement('img');
const testPath = '/img/testimg.png'; const testPath = '/img/testimg.png';
newImg.className = 'lazy'; newImg.className = 'lazy';
...@@ -41,7 +41,7 @@ describe('LazyLoader', function () { ...@@ -41,7 +41,7 @@ describe('LazyLoader', function () {
}, 100); }, 100);
}); });
it('should not alter normal images', function (done) { it('should not alter normal images', function(done) {
const newImg = document.createElement('img'); const newImg = document.createElement('img');
const testPath = '/img/testimg.png'; const testPath = '/img/testimg.png';
newImg.setAttribute('src', testPath); newImg.setAttribute('src', testPath);
......
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