Commit d42a943c authored by Tim Zallmann's avatar Tim Zallmann

Merge branch '31667-improve-karma-assertion-on-mock' into 'master'

Improve assertion on mock to include parameter

Closes #31667

See merge request gitlab-org/gitlab!17801
parents 34a359dc e317e922
...@@ -62,7 +62,7 @@ describe('LazyLoader', function() { ...@@ -62,7 +62,7 @@ describe('LazyLoader', function() {
waitForAttributeChange(newImg, ['data-src', 'src']), waitForAttributeChange(newImg, ['data-src', 'src']),
]) ])
.then(() => { .then(() => {
expect(LazyLoader.loadImage).toHaveBeenCalled(); expect(LazyLoader.loadImage).toHaveBeenCalledWith(newImg);
expect(newImg.getAttribute('src')).toBe(testPath); expect(newImg.getAttribute('src')).toBe(testPath);
expect(newImg).toHaveClass('js-lazy-loaded'); expect(newImg).toHaveClass('js-lazy-loaded');
done(); done();
...@@ -79,7 +79,7 @@ describe('LazyLoader', function() { ...@@ -79,7 +79,7 @@ describe('LazyLoader', function() {
scrollIntoViewPromise(newImg) scrollIntoViewPromise(newImg)
.then(waitForPromises) .then(waitForPromises)
.then(() => { .then(() => {
expect(LazyLoader.loadImage).not.toHaveBeenCalled(); expect(LazyLoader.loadImage).not.toHaveBeenCalledWith(newImg);
expect(newImg).not.toHaveClass('js-lazy-loaded'); expect(newImg).not.toHaveClass('js-lazy-loaded');
done(); done();
}) })
...@@ -98,7 +98,7 @@ describe('LazyLoader', function() { ...@@ -98,7 +98,7 @@ describe('LazyLoader', function() {
scrollIntoViewPromise(newImg) scrollIntoViewPromise(newImg)
.then(waitForPromises) .then(waitForPromises)
.then(() => { .then(() => {
expect(LazyLoader.loadImage).not.toHaveBeenCalled(); expect(LazyLoader.loadImage).not.toHaveBeenCalledWith(newImg);
expect(newImg).not.toHaveClass('js-lazy-loaded'); expect(newImg).not.toHaveClass('js-lazy-loaded');
done(); done();
}) })
...@@ -121,7 +121,7 @@ describe('LazyLoader', function() { ...@@ -121,7 +121,7 @@ describe('LazyLoader', function() {
]) ])
.then(waitForPromises) .then(waitForPromises)
.then(() => { .then(() => {
expect(LazyLoader.loadImage).toHaveBeenCalled(); expect(LazyLoader.loadImage).toHaveBeenCalledWith(newImg);
expect(newImg).toHaveClass('js-lazy-loaded'); expect(newImg).toHaveClass('js-lazy-loaded');
done(); done();
}) })
...@@ -156,7 +156,7 @@ describe('LazyLoader', function() { ...@@ -156,7 +156,7 @@ describe('LazyLoader', function() {
Promise.all([scrollIntoViewPromise(img), waitForAttributeChange(img, ['data-src', 'src'])]) Promise.all([scrollIntoViewPromise(img), waitForAttributeChange(img, ['data-src', 'src'])])
.then(() => { .then(() => {
expect(LazyLoader.loadImage).toHaveBeenCalled(); expect(LazyLoader.loadImage).toHaveBeenCalledWith(img);
expect(img.getAttribute('src')).toBe(originalDataSrc); expect(img.getAttribute('src')).toBe(originalDataSrc);
expect(img).toHaveClass('js-lazy-loaded'); expect(img).toHaveClass('js-lazy-loaded');
done(); done();
...@@ -176,7 +176,7 @@ describe('LazyLoader', function() { ...@@ -176,7 +176,7 @@ describe('LazyLoader', function() {
waitForAttributeChange(newImg, ['data-src', 'src']), waitForAttributeChange(newImg, ['data-src', 'src']),
]) ])
.then(() => { .then(() => {
expect(LazyLoader.loadImage).toHaveBeenCalled(); expect(LazyLoader.loadImage).toHaveBeenCalledWith(newImg);
expect(newImg.getAttribute('src')).toBe(testPath); expect(newImg.getAttribute('src')).toBe(testPath);
expect(newImg).toHaveClass('js-lazy-loaded'); expect(newImg).toHaveClass('js-lazy-loaded');
done(); done();
...@@ -193,7 +193,7 @@ describe('LazyLoader', function() { ...@@ -193,7 +193,7 @@ describe('LazyLoader', function() {
scrollIntoViewPromise(newImg) scrollIntoViewPromise(newImg)
.then(waitForPromises) .then(waitForPromises)
.then(() => { .then(() => {
expect(LazyLoader.loadImage).not.toHaveBeenCalled(); expect(LazyLoader.loadImage).not.toHaveBeenCalledWith(newImg);
expect(newImg).not.toHaveClass('js-lazy-loaded'); expect(newImg).not.toHaveClass('js-lazy-loaded');
done(); done();
}) })
...@@ -212,7 +212,7 @@ describe('LazyLoader', function() { ...@@ -212,7 +212,7 @@ describe('LazyLoader', function() {
scrollIntoViewPromise(newImg) scrollIntoViewPromise(newImg)
.then(waitForPromises) .then(waitForPromises)
.then(() => { .then(() => {
expect(LazyLoader.loadImage).not.toHaveBeenCalled(); expect(LazyLoader.loadImage).not.toHaveBeenCalledWith(newImg);
expect(newImg).not.toHaveClass('js-lazy-loaded'); expect(newImg).not.toHaveClass('js-lazy-loaded');
done(); done();
}) })
...@@ -234,7 +234,7 @@ describe('LazyLoader', function() { ...@@ -234,7 +234,7 @@ describe('LazyLoader', function() {
waitForAttributeChange(newImg, ['data-src', 'src']), waitForAttributeChange(newImg, ['data-src', 'src']),
]) ])
.then(() => { .then(() => {
expect(LazyLoader.loadImage).toHaveBeenCalled(); expect(LazyLoader.loadImage).toHaveBeenCalledWith(newImg);
expect(newImg).toHaveClass('js-lazy-loaded'); expect(newImg).toHaveClass('js-lazy-loaded');
done(); done();
}) })
......
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