Browse Source

Update tests Css Composer

pull/14/head
Artur Arseniev 10 years ago
parent
commit
0333d54d5a
  1. 3
      src/css_composer/view/CssRulesView.js
  2. 7
      test/specs/css_composer/main.js
  3. 54
      test/specs/css_composer/view/CssRulesView.js

3
src/css_composer/view/CssRulesView.js

@ -6,8 +6,7 @@ define(['backbone','./CssRuleView'],
return Backbone.View.extend({ return Backbone.View.extend({
initialize: function(o) { initialize: function(o) {
this.config = o.config; this.config = o.config || {};
this.preview = o.preview;
this.pfx = this.config.stylePrefix; this.pfx = this.config.stylePrefix;
this.listenTo( this.collection, 'add', this.addTo ); this.listenTo( this.collection, 'add', this.addTo );
this.listenTo( this.collection, 'reset', this.render ); this.listenTo( this.collection, 'reset', this.render );

7
test/specs/css_composer/main.js

@ -3,12 +3,14 @@ var modulePath = './../../../test/specs/css_composer';
define([ define([
'CssComposer', 'CssComposer',
modulePath + '/model/CssModels', modulePath + '/model/CssModels',
modulePath + '/view/CssRuleView' modulePath + '/view/CssRuleView',
modulePath + '/view/CssRulesView'
], ],
function( function(
CssComposer, CssComposer,
Models, Models,
CssRuleView CssRuleView,
CssRulesView
) { ) {
describe('Css Composer', function() { describe('Css Composer', function() {
@ -132,6 +134,7 @@ define([
Models.run(); Models.run();
CssRuleView.run(); CssRuleView.run();
CssRulesView.run();
}); });
}); });

54
test/specs/css_composer/view/CssRulesView.js

@ -0,0 +1,54 @@
var path = 'CssComposer/view/';
define([path + 'CssRulesView', 'CssComposer/model/CssRules'],
function(CssRulesView, CssRules) {
return {
run : function(){
describe('CssRulesView', function() {
before(function () {
this.$fixtures = $("#fixtures");
this.$fixture = $('<div class="cssrules-fixture"></div>');
});
beforeEach(function () {
var col = new CssRules([]);
this.view = new CssRulesView({
collection: col
});
this.$fixture.empty().appendTo(this.$fixtures);
this.$fixture.html(this.view.render().el);
});
afterEach(function () {
this.view.collection.reset();
});
after(function () {
this.$fixture.remove();
});
it('Object exists', function() {
CssRulesView.should.be.exist;
});
it("Collection is empty", function (){
this.view.$el.html().should.be.empty;
});
it("Add new rule", function (){
sinon.stub(this.view, "addToCollection");
this.view.collection.add({});
this.view.addToCollection.calledOnce.should.equal(true);
});
it("Render new rule", function (){
this.view.collection.add({});
this.view.$el.html().should.not.be.empty;
});
});
}
};
});
Loading…
Cancel
Save