Free and Open source Web Builder Framework. Next generation tool for building templates without coding
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

38 lines
1.2 KiB

import Component from 'dom_components/model/Component';
import ComponentImage from 'dom_components/model/ComponentImage';
describe('ComponentImage', () => {
let componentImage;
beforeEach(() => {
componentImage = new ComponentImage();
});
test('`src` property is defined after initializing', () => {
expect(componentImage.get('src')).toBeDefined();
});
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 });
});
});
});