I am building a client-side web application in javascript. To build the templates I have used HandleBars.js templates, i.e. .hbs files. I am using Jasmine framework for writing the specs for the JavaScript Code. But I am stuck on loading the .hbs templates from the source files in the specs.
Using the Jasmine-Jquery (Link) plugin I have included the static html templates.
This is part of a sample template :
<li>
<div class="fixedText">
<div class="middleItem">Name</div>
<div class="midItemValue" style = "margin-right: 0.6rem;">
<input id = "textNewGroupName" type="text" style = "width : 300px;" maxlength="300" name="name" value="{{name}}">
</div>
</div>
</li>
included in the hbs file. Because of the similar dynamic values (here name) in the templates I am unable to use the static fixture method.
I found below example by the link that I given in the question, and that fixture is used for HTML
loadFixtures('myfixture.html');
// Run test
some.methodToTest();
// Expect that the methodToTest has modified the content in the div
expect($('#fixtureId')).to...;
I found the answer for HBS also, and it is as follows:-
myfixture.html
, I loaded my HBS file
.Handlebars.compile('myFixture.hbs')