You want to spy on the afterRender call and check the spy in the positive and negative test. I don't use Sinon.js, but here's a way to do it with JS and Jasmine's spies:
describe("MyView", function() {
var view;
beforeEach(function() {
view = new View();
spyOn(view, 'afterRender');
});
describe("when render is called", function() {
beforeEach(function() {
view.render();
});
it("should call the afterRender callback", function() {
expect(view.afterRender).toHaveBeenCalled();
});
});
describe("when foo is called", function() {
beforeEach(function() {
view.foo();
});
it("should call the afterRender callback", function() {
expect(view.afterRender).not.toHaveBeenCalled();
});
});
})