+
+
+ describe('ZWS', function() {
+ var view, section, textElement;
+
+ beforeEach(function() {
+ var c = canvas.fromXML('<section></section>');
+
+ section = c.doc();
+ textElement = section.children()[0];
+ view = c.view()[0];
+ document.getElementsByTagName('body')[0].appendChild(view);
+ });
+
+ afterEach(function() {
+ view.parentNode.removeChild(view);
+ });
+
+ var getTextContainerNode = function(textElement) {
+ return textElement.dom().contents()[0];
+ }
+
+ it('is set automatically on all empty DocumentTextElements', function() {
+ expect(getTextContainerNode(textElement).data).to.equal(utils.unicode.ZWS);
+
+ var header = section.append({tag: 'header'}),
+ newText = header.append({text: ''}),
+ textNode = getTextContainerNode(textElement);
+
+ expect(textNode.data).to.equal(utils.unicode.ZWS);
+ });
+
+ it('is added automatically when whole text gets deleted', function() {
+ getTextContainerNode(textElement).data = '';
+
+ window.setTimeout(function() {
+ expect(getTextContainerNode(textElement).data).to.equal(utils.unicode.ZWS);
+ }, 0)
+
+ var header = section.append({tag: 'header'}),
+ newText = header.append({text: 'Alice'}),
+ textNode = getTextContainerNode(newText);
+
+ expect(textNode.data).to.have.length('Alice'.length);
+ textNode.data = '';
+
+ window.setTimeout(function() {
+ expect(textNode.data).to.equal(utils.unicode.ZWS);
+ }, 0)
+ });
+ });
+