Skip to content

Commit

Permalink
Merge pull request #2620 from mcottret/fix/fix-default-image-placehol…
Browse files Browse the repository at this point in the history
…der-src

Fix ComponentImage's default src not being base64 encoded. Fixes #2619
  • Loading branch information
artf authored Mar 5, 2020
2 parents 60508ae + ba27279 commit 104f521
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 12 deletions.
41 changes: 30 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/dom_components/model/ComponentImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default Component.extend(
*/
getAttrToHTML(...args) {
const attr = Component.prototype.getAttrToHTML.apply(this, args);
const src = this.get('src');
const src = this.getSrcResult();
if (src) attr.src = src;
return attr;
},
Expand Down
34 changes: 34 additions & 0 deletions test/specs/dom_components/model/ComponentImage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import Component from '../../../../src/dom_components/model/Component';
import ComponentImage from '../../../../src/dom_components/model/ComponentImage';

describe('ComponentImage', () => {
let componentImage;

beforeEach(() => {
componentImage = new ComponentImage();
});

describe('.getAttrToHTML', () => {
let getSrcResultSpy;
const fakeAttributes = {};

beforeEach(() => {
spyOn(Component.prototype, 'getAttrToHTML').and.returnValue(
fakeAttributes
);
getSrcResultSpy = spyOn(componentImage, 'getSrcResult');
});

test('it should fill the `src` property with the result of `getSrcResult` if defined', () => {
let attributes = componentImage.getAttrToHTML();
expect(getSrcResultSpy).toHaveBeenCalled();
expect(attributes).toEqual(fakeAttributes);

let fakeSrcResult = 'fakeSrcResult';
getSrcResultSpy.and.returnValue(fakeSrcResult);
attributes = componentImage.getAttrToHTML();
expect(getSrcResultSpy).toHaveBeenCalledTimes(2);
expect(attributes).toEqual({ src: fakeSrcResult });
});
});
});

0 comments on commit 104f521

Please sign in to comment.