Skip to content

Instantly share code, notes, and snippets.

@sminutoli
Created September 13, 2016 14:46
Show Gist options
  • Save sminutoli/dcca8e80055165a811da11e1f72983f8 to your computer and use it in GitHub Desktop.
Save sminutoli/dcca8e80055165a811da11e1f72983f8 to your computer and use it in GitHub Desktop.
describe('Item', ()=>{
function setup(){
const data = {
name: 'test',
image: 'http://placeimg.com/400/300/people/grayscale',
available: true
};
const anItem = Item.from(data);
return { data, anItem };
}
it('should delegate on EnhancedObject', ()=>{
const actual = EnhancedObject.isPrototypeOf(Item);
expect(actual).toBe(true);
});
it('should delegate on Renderizable', ()=>{
const actual = Renderizable.isPrototypeOf(Item);
expect(actual).toBe(true);
});
it('should render the title', ()=>{
const { data, anItem } = setup();
const html = anItem.toHTML();
const actual = $(html).find('h2').text();
expect(actual).toBe(data.name);
});
it('should render the image', ()=>{
const { data, anItem } = setup();
const html = anItem.toHTML();
const actual = $(html).find('img').attr('src');
expect(actual).toBe(data.image);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment