const BaseXform = require('../base-xform');


class HeaderFooterXform extends BaseXform {
  get tag() {
    return 'headerFooter';
  }

  render(xmlStream, model) {
    if (model) {
      xmlStream.openNode('headerFooter');
      if (model.differentFirst) {
        xmlStream.addAttribute('differentFirst', '1');
      }
      if (model.differentOddEven) {
        xmlStream.addAttribute('differentOddEven', '1');
      }

      if (model.oddHeader !== null) {
        xmlStream.leafNode('oddHeader', null, model.oddHeader);
      }
      if (model.oddFooter !== null) {
        xmlStream.leafNode('oddFooter', null, model.oddFooter);
      }
      if (model.evenHeader !== null) {
        xmlStream.leafNode('evenHeader', null, model.evenHeader);
      }
      if (model.evenFooter !== null) {
        xmlStream.leafNode('evenFooter', null, model.evenFooter);
      }
      if (model.firstHeader !== null) {
        xmlStream.leafNode('firstHeader', null, model.firstHeader);
      }
      if (model.firstFooter !== null) {
        xmlStream.leafNode('firstFooter', null, model.firstFooter);
      }

      xmlStream.closeNode();
    }
  }
}

module.exports = HeaderFooterXform;
@@ -38,17 +38,16 @@
 orm');%0A%0A
-%0A
 class He
@@ -410,25 +410,24 @@
 ');%0A      %7D%0A
-%0A
       if (mo
@@ -436,32 +436,62 @@
 l.oddHeader 
-!== null
+&& typeof model.oddHeader === 'string'
 ) %7B%0A        
@@ -576,32 +576,62 @@
 l.oddFooter 
-!== null
+&& typeof model.oddFooter === 'string'
 ) %7B%0A        
@@ -717,32 +717,63 @@
 .evenHeader 
-!== null
+&& typeof model.evenHeader === 'string'
 ) %7B%0A        
@@ -861,32 +861,63 @@
 .evenFooter 
-!== null
+&& typeof model.evenFooter === 'string'
 ) %7B%0A        
@@ -1010,24 +1010,56 @@
 tHeader 
-!== null
+&& typeof model.firstHeader === 'string'
 ) %7B%0A    
@@ -1162,16 +1162,48 @@
 ter 
-!== null
+&& typeof model.firstFooter === 'string'
 ) %7B%0A
@@ -1279,16 +1279,16 @@
      %7D%0A%0A
-
       xm
@@ -1317,16 +1317,1881 @@
    %7D%0A  %7D
+%0A%0A  parseOpen(node) %7B%0A    switch (node.name) %7B%0A      case 'headerFooter':%0A        this.model = %7B%7D;%0A        if (node.attributes.differentFirst) %7B%0A          this.model.differentFirst = parseInt(node.attributes.differentFirst, 0) === 1;%0A        %7D%0A        if (node.attributes.differentOddEven) %7B%0A          this.model.differentOddEven = parseInt(node.attributes.differentOddEven, 0) === 1;%0A        %7D%0A        return true;%0A%0A      case 'oddHeader':%0A        this.currentNode = 'oddHeader';%0A        return true;%0A%0A      case 'oddFooter':%0A        this.currentNode = 'oddFooter';%0A        return true;%0A%0A      case 'evenHeader':%0A        this.currentNode = 'evenHeader';%0A        return true;%0A%0A      case 'evenFooter':%0A        this.currentNode = 'evenFooter';%0A        return true;%0A%0A      case 'firstHeader':%0A        this.currentNode = 'firstHeader';%0A        return true;%0A%0A      case 'firstFooter':%0A        this.currentNode = 'firstFooter';%0A        return true;%0A%0A      default:%0A        return false;%0A    %7D%0A  %7D%0A%0A  parseText(text) %7B%0A    switch (this.currentNode) %7B%0A      case 'oddHeader':%0A        this.model.oddHeader = text;%0A        break;%0A%0A      case 'oddFooter':%0A        this.model.oddFooter = text;%0A        break;%0A%0A      case 'evenHeader':%0A        this.model.evenHeader = text;%0A        break;%0A%0A      case 'evenFooter':%0A        this.model.evenFooter = text;%0A        break;%0A%0A      case 'firstHeader':%0A        this.model.firstHeader = text;%0A        break;%0A%0A      case 'firstFooter':%0A        this.model.firstFooter = text;%0A        break;%0A%0A      default:%0A        break;%0A    %7D%0A  %7D%0A%0A  parseClose() %7B%0A    switch (this.currentNode) %7B%0A      case 'oddHeader':%0A      case 'oddFooter':%0A      case 'evenHeader':%0A      case 'evenFooter':%0A      case 'firstHeader':%0A      case 'firstFooter':%0A        this.currentNode = undefined;%0A        return true;%0A%0A      default:%0A        return false;%0A    %7D%0A  %7D
 %0A%7D%0A%0Amodu

Fix error on adding unit test for header-footer-xform