mirror of https://github.com/artf/grapesjs.git
5 changed files with 67 additions and 11 deletions
@ -0,0 +1,57 @@ |
|||||
|
var path = 'DomComponents/view/'; |
||||
|
define([path + 'ComponentImageView', 'DomComponents/model/Component'], |
||||
|
function(ComponentImageView, Component) { |
||||
|
|
||||
|
return { |
||||
|
run : function(){ |
||||
|
|
||||
|
describe('ComponentImageView', function() { |
||||
|
|
||||
|
var $fixtures; |
||||
|
var $fixture; |
||||
|
var model; |
||||
|
var view; |
||||
|
|
||||
|
before(function () { |
||||
|
$fixtures = $("#fixtures"); |
||||
|
$fixture = $('<div class="components-fixture"></div>'); |
||||
|
}); |
||||
|
|
||||
|
beforeEach(function () { |
||||
|
model = new Component(); |
||||
|
view = new ComponentImageView({ |
||||
|
model: model |
||||
|
}); |
||||
|
$fixture.empty().appendTo($fixtures); |
||||
|
$fixture.html(view.render().el); |
||||
|
}); |
||||
|
|
||||
|
afterEach(function () { |
||||
|
view.remove(); |
||||
|
}); |
||||
|
|
||||
|
after(function () { |
||||
|
$fixture.remove(); |
||||
|
}); |
||||
|
|
||||
|
it('Component empty', function() { |
||||
|
$fixture.html().should.equal('<img class="image-placeholder">'); |
||||
|
}); |
||||
|
|
||||
|
it('TagName is <img>', function() { |
||||
|
view.el.tagName.should.equal('IMG'); |
||||
|
}); |
||||
|
|
||||
|
it('Update src attribute', function() { |
||||
|
model.set('src','./'); |
||||
|
view.el.getAttribute('src').should.equal('./'); |
||||
|
}); |
||||
|
|
||||
|
it('Renders correctly', function() { |
||||
|
view.render().should.be.ok; |
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
}); |
||||
Loading…
Reference in new issue