I'm working on a navbar partial view called _navbar.html.erb.
<nav class="nav-links">
<ul>
<li><%= link_to "Mastermind", root_path, :id => 'logo'%></li>
</ul>
</nav>
Clicking on "Mastermind" reloads the page using the following JavaScript functions:
function reloadPage() {
location.reload();
}
function logoReload() {
$('#logo').click(reloadPage);
}
However, my jasmine test to check if the button click triggers a page reload is failing. Here's the code snippet for the test:
describe("button click", function() {
var btn;
beforeEach(function() {
btn = $('#logo');
});
it("should reload the page", function() {
spyOn(window, 'reloadPage');
$(btn).click();
expect(window.reloadPage).toHaveBeenCalled();
});
});
The error message I receive is: Error: Expected spy reloadPage to have been called.
If anyone has any insights or ideas on why this may not be working as expected, I would greatly appreciate it!