[Test Conductor] Add test case for requery

WTD-1515
This commit is contained in:
Victor Woeltjen 2015-09-16 17:00:56 -07:00
parent 8f24e014e0
commit de71bde62f

View File

@ -45,6 +45,14 @@ define(
}; };
} }
function fireEvent(name, args) {
mockScope.$on.calls.forEach(function (call) {
if (call.args[0] === name) {
call.args[1].apply(null, args || []);
}
});
}
beforeEach(function () { beforeEach(function () {
mockScope = jasmine.createSpyObj( mockScope = jasmine.createSpyObj(
@ -87,6 +95,7 @@ define(
mockHandle.getMetadata.andReturn([{}]); mockHandle.getMetadata.andReturn([{}]);
mockHandle.getDomainValue.andReturn(123); mockHandle.getDomainValue.andReturn(123);
mockHandle.getRangeValue.andReturn(42); mockHandle.getRangeValue.andReturn(42);
mockScope.domainObject = mockDomainObject;
controller = new PlotController( controller = new PlotController(
mockScope, mockScope,
@ -238,10 +247,20 @@ define(
// Also verify precondition // Also verify precondition
expect(mockHandle.unsubscribe).not.toHaveBeenCalled(); expect(mockHandle.unsubscribe).not.toHaveBeenCalled();
// Destroy the scope // Destroy the scope
mockScope.$on.mostRecentCall.args[1](); fireEvent("$destroy");
// Should have unsubscribed // Should have unsubscribed
expect(mockHandle.unsubscribe).toHaveBeenCalled(); expect(mockHandle.unsubscribe).toHaveBeenCalled();
}); });
it("requeries when displayable bounds change", function () {
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
expect(mockHandle.request.calls.length).toEqual(1);
fireEvent("telemetry:display:bounds", [
{},
{ start: 10, end: 100 }
]);
expect(mockHandle.request.calls.length).toEqual(2);
});
}); });
} }
); );