decojs
Version:
Scalable frontend architecture
51 lines (39 loc) • 980 B
JavaScript
describe("when the viewmodel is destroyed", {
"deco/spa/hashNavigation": "Mocks/hashNavigationMock"
},[
"deco/spa",
"Given/an_element",
"Given/a_document",
"deco/spa/hashNavigation"
], function(
spa,
an_element,
a_document,
hashNavigationMock
){
var react;
beforeEach(function(done){
var doc = a_document.withAnOutlet("DestroyVM");
react = sinon.spy();
define("DestroyVM", [], function(){
return function DestroyVM(model, when){
when.thisIsDestroyed(react);
done();
};
});
spa.start({}, doc).then(function(){
hashNavigationMock.navigateToPage("index");
});
});
afterEach(function(){
require.undef("DestroyVM");
});
describe("when the page changes", function(){
beforeEach(function(){
hashNavigationMock.navigateToPage("destroy/viewmodel/path");
});
it("should call the onDestroy listener", function(){
expect(react.callCount).toBe(1);
});
});
});