Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ class Result {
body = HTMLSerializer.serializeChildren(body);

this._head = head;
this._body = body;

// Adding script boundary around the body
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for when domContents is called these script boundaries are always present?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @kratiahuja, I added unit tests to verify domContents.body will always include boundary script tags.

this._body = `<script type="x/boundary" id="fastboot-body-start"></script>${body}<script type="x/boundary" id="fastboot-body-end"></script>`;
}
}

Expand All @@ -190,7 +192,7 @@ function insertIntoIndexHTML(html, htmlAttributes, head, body, bodyAttributes) {
return head;
} else if (tag === 'BODY' && body && !isBodyReplaced) {
isBodyReplaced = true;
return '<script type="x/boundary" id="fastboot-body-start"></script>' + body + '<script type="x/boundary" id="fastboot-body-end"></script>';
return body;
}
return '';
});
Expand Down
23 changes: 23 additions & 0 deletions test/result-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,27 @@ describe('Result', function() {
});
});
});

describe('domContents()', function() {
var HEAD = '<meta name="foo" content="bar">';
var BODY = '<h1>A normal response document</h1>';
var boundaryStartTag = '<script type="x/boundary" id="fastboot-body-start"></script>';
var boundaryEndTag = '<script type="x/boundary" id="fastboot-body-end"></script>';

beforeEach(function () {
doc.head.appendChild(doc.createRawHTMLSection(HEAD));
doc.body.appendChild(doc.createRawHTMLSection(BODY));

result._finalize();
});

it('should return the FastBoot-rendered document body', function () {
var domContents = result.domContents();
expect(domContents.head).to.include(HEAD);
expect(domContents.body).to.include(BODY);
expect(domContents.body).to.include(boundaryStartTag);
expect(domContents.body).to.include(boundaryEndTag);
expect(domContents.body).to.equal(boundaryStartTag+BODY+boundaryEndTag);
});
});
});