Hi all,
I want to avoid duplicating code to test DOM elements, so I don't want to use an HTML fuxture but a CSHTML fixture directly from my C# project.
I am able to load the CSHTML fixture in my tests files, but those elements that use Razor are not being compiled:
<div class="message error validation-summary-errors" id="errormsg" data-loin="@T("Error Message Login")"></div>
In my Unit Test I expect $("#errormsg") to have some HTML
it("if user name is empty it should return an error message", function () {
$("#UserName").css("color") == "rgb(128, 128, 128)";
writeMsgLogin()
CheckValue(event)
expect($("#errormsg")).toHaveHtml(msgLogin);
});
writeMsgLogin() is defined in a separate js:
function writeMsgLogin() {
msgLogin = "<ul><li>" + $("#errormsg").data("login") + "</li></ul>";
}
But @T("Error Message Login") is not compiled (the text should be taken from a .PO file) and so the test fails:
Test Name: Login Form No Captcha if user name is empty it should return an error message
Test FullName: c:\gms\dev\gms_portal\kpmg.tax.gms.portal.testjs\tests\loginform.js::login form no captcha::if user name is empty it should return an error message
Test Source: c:\gms\dev\gms_portal\kpmg.tax.gms.portal.testjs\tests\loginform.js : line 26
Test Outcome: Failed
Test Duration: 0:00:00.007
Result Message: Expected ({ 0: HTMLNode, length: 1, context: HTMLNode, selector: '#errormsg' }) to have html '<ul><li>@T(</li></ul>'.
Does anyone know how to test content rendered with Razor in a View using Jasmine+Chutzpah?
Thanks