[Mobile] Tests

Completed tests for AgentService,
InfoService, and ContextMenuAction.
ContextMenu and InfoButton Gesture
tests remain. Also resized info button
icon.
This commit is contained in:
Shivam Dave
2015-08-04 16:48:41 -07:00
parent 66408eeec8
commit 6b65ae77e7
8 changed files with 147 additions and 18 deletions

View File

@@ -53,6 +53,14 @@ define(
mockStopPropagation,
action;
function fireEvent(evt, value) {
mockElement.on.calls.forEach(function (call) {
if (call.args[0] === evt) {
call.args[1](value);
}
});
}
beforeEach(function () {
mockCompile = jasmine.createSpy("$compile");
mockCompiledTemplate = jasmine.createSpy("template");
@@ -144,13 +152,12 @@ define(
it("keeps a menu when menu is clicked", function () {
// Show the menu
action.perform();
// Find and fire body's mousedown listener
// mockMenu.on.calls.forEach(function (call) {
// if (call.args[0] === 'mousedown') {
// call.args[1]();
// }
// });
mockMenu.on.calls.forEach(function (call) {
if (call.args[0] === 'mousedown') {
call.args[1](mockEvent);
}
});
// Menu should have been removed
expect(mockMenu.remove).not.toHaveBeenCalled();
@@ -171,11 +178,11 @@ define(
);
action.perform();
// mockMenu.on.calls.forEach(function (call) {
// if (call.args[0] === 'touchstart') {
// call.args[1]();
// }
// });
mockMenu.on.calls.forEach(function (call) {
if (call.args[0] === 'touchstart') {
call.args[1](mockEvent);
}
});
});
});
}

View File

@@ -82,10 +82,11 @@ define(
// Capture the contextmenu callback
fireGesture = mockElement.on.mostRecentCall.args[1];
expect(mockElement.on).toHaveBeenCalledWith(
"touchstart",
jasmine.any(Function)
);
mockMenu.on.calls.forEach(function (call) {
if (call.args[0] === 'touchstart') {
call.args[1](mockEvent);
}
});
});
});
}