diff --git a/spec/parser/javascript/node_spec.js b/spec/parser/javascript/node_spec.js index 5367de8..2c2680b 100644 --- a/spec/parser/javascript/node_spec.js +++ b/spec/parser/javascript/node_spec.js @@ -217,26 +217,6 @@ describe('parser/javascript/node.js', function() { }); - describe('#startRender', function() { - - it('increments the renderCounter', function() { - this.node.state.renderCounter = 0; - this.node.startRender(); - expect(this.node.state.renderCounter).toEqual(1); - }); - - }); - - describe('#doneRender', function() { - - it('decrements the renderCounter', function() { - this.node.state.renderCounter = 42; - this.node.doneRender(); - expect(this.node.state.renderCounter).toEqual(41); - }); - - }); - describe('#render', function() { beforeEach(function() { @@ -267,8 +247,6 @@ describe('parser/javascript/node.js', function() { beforeEach(function() { this.deferred = this.testablePromise(); this.node._render = jasmine.createSpy('_render').and.returnValue(this.deferred.promise); - spyOn(this.node, 'startRender'); - spyOn(this.node, 'doneRender'); }); it('sets the container', function() { @@ -276,9 +254,10 @@ describe('parser/javascript/node.js', function() { expect(this.node.container).toEqual(this.container); }); - it('calls #startRender', function() { + it('increments the renderCounter', function() { + this.node.state.renderCounter = 0; this.node.render(this.container); - expect(this.node.startRender).toHaveBeenCalled(); + expect(this.node.state.renderCounter).toEqual(1); }); it('calls #_render', function() { @@ -288,19 +267,18 @@ describe('parser/javascript/node.js', function() { describe('when #_render is complete', function() { - beforeEach(function() { + it('decrements the renderCounter', function(done) { + this.node.render(this.container) + .then(() => { + expect(this.node.state.renderCounter).toEqual(41); + done(); + }); + this.node.state.renderCounter = 42; this.deferred.resolve(); }); - it('calls #doneRender', function(done) { - this.node.render(this.container) - .then(() => { - expect(this.node.doneRender).toHaveBeenCalled(); - done(); - }); - }); - it('ultimately resolves with the node instance', function(done) { + this.deferred.resolve(); this.node.render(this.container) .then(result => { expect(result).toEqual(this.node); diff --git a/src/js/parser/javascript/node.js b/src/js/parser/javascript/node.js index 722ff4c..58836e4 100644 --- a/src/js/parser/javascript/node.js +++ b/src/js/parser/javascript/node.js @@ -59,6 +59,23 @@ export default class Node { }); } + render(container) { + if (container) { + this.container = container; + } + + if (this.proxy) { + return this.proxy.render(this.container); + } else { + this.state.renderCounter++; + return this._render() + .then(() => { + this.state.renderCounter--; + return this; + }); + } + } + renderLabel(text) { var group = this.container.group() .addClass('label'), @@ -82,34 +99,6 @@ export default class Node { }); } - startRender() { - this.state.renderCounter++; - } - - doneRender() { - this.state.renderCounter--; - } - - render(container) { - if (container) { - this.container = container; - } - - if (this.proxy) { - return this.proxy.render(this.container); - } else { - this.startRender(); - return this._render() - .then( - () => { - this.doneRender(); - return this; - }, - null - ); - } - } - renderLabeledBox(label, content, options) { var label = this.container.text(0, 0, label) .addClass([this.type, 'label'].join('-')),