Skip to content

Commit

Permalink
magento/adobe-stock-integration#1387: Uncaught TypeError: Cannot read…
Browse files Browse the repository at this point in the history
… property 'complete' of undefined appears in dev console if save Previewed image as a new View and open this View on another page - fix static test and unit test
  • Loading branch information
joweecaquicla committed Aug 20, 2020
1 parent e2e6b3e commit d24d07d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,18 @@ define([
$(document).on('keydown', this.handleKeyDown.bind(this));

this.lastOpenedImage.subscribe(function (newValue) {

if (newValue === false && _.isNull(this.visibleRecord())) {
return;
}

if (newValue === this.visibleRecord()) {
return;
}

if (newValue === false) {
this.hide();

return;
}

Expand Down Expand Up @@ -170,16 +173,14 @@ define([
setTimeout(function () {
this.updateImageData();
}.bind(this), 100);
} else if (img.get(0).complete) {
this.updateHeight();
this.scrollToPreview();
} else {
if (img.get(0).complete) {
img.load(function () {
this.updateHeight();
this.scrollToPreview();
} else {
img.load(function () {
this.updateHeight();
this.scrollToPreview();
}.bind(this));
}
}.bind(this));
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ define([
originMock = $.fn.get;

spyOn($.fn, 'get').and.returnValue(imageMock);
imagePreview.lastOpenedImage = jasmine.createSpy().and.returnValue(2);
imagePreview.visibleRecord = jasmine.createSpy().and.returnValue(2);
imagePreview.displayedRecord = ko.observable();
imagePreview.displayedRecord(recordMock);
Expand Down

0 comments on commit d24d07d

Please sign in to comment.