[Mobile] Tests
Has way to make isMobile call true or false for mobile/nonmobile devices.
This commit is contained in:
@@ -49,6 +49,8 @@ define(
|
|||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
mockEvent,
|
mockEvent,
|
||||||
mockActionContext,
|
mockActionContext,
|
||||||
|
mockNavigator,
|
||||||
|
mockStopPropagation,
|
||||||
action;
|
action;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
@@ -63,7 +65,7 @@ define(
|
|||||||
mockScope = {};
|
mockScope = {};
|
||||||
mockElement = jasmine.createSpyObj("element", JQLITE_FUNCTIONS);
|
mockElement = jasmine.createSpyObj("element", JQLITE_FUNCTIONS);
|
||||||
mockDomainObject = jasmine.createSpyObj("domainObject", DOMAIN_OBJECT_METHODS);
|
mockDomainObject = jasmine.createSpyObj("domainObject", DOMAIN_OBJECT_METHODS);
|
||||||
mockEvent = jasmine.createSpyObj("event", ["preventDefault"]);
|
mockEvent = jasmine.createSpyObj("event", ["preventDefault", "stopPropagation"]);
|
||||||
mockEvent.pageX = 0;
|
mockEvent.pageX = 0;
|
||||||
mockEvent.pageY = 0;
|
mockEvent.pageY = 0;
|
||||||
|
|
||||||
@@ -138,6 +140,44 @@ define(
|
|||||||
// Listener should have been detached from body
|
// Listener should have been detached from body
|
||||||
expect(mockBody.off).toHaveBeenCalled();
|
expect(mockBody.off).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("keeps a menu when menu is clicked", function () {
|
||||||
|
// Show the menu
|
||||||
|
mockEvent
|
||||||
|
action.perform();
|
||||||
|
|
||||||
|
// Find and fire body's mousedown listener
|
||||||
|
mockMenu.on.calls.forEach(function (call) {
|
||||||
|
if (call.args[0] === 'mousedown') {
|
||||||
|
// call.args[1]();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Menu should have been removed
|
||||||
|
expect(mockMenu.remove).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
// Listener should have been detached from body
|
||||||
|
expect(mockBody.off).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("mobile", function () {
|
||||||
|
mockQueryService.isMobile.andReturn(true);
|
||||||
|
action = new ContextMenuAction(
|
||||||
|
mockCompile,
|
||||||
|
mockDocument,
|
||||||
|
mockWindow,
|
||||||
|
mockRootScope,
|
||||||
|
mockQueryService,
|
||||||
|
mockActionContext
|
||||||
|
);
|
||||||
|
action.perform();
|
||||||
|
|
||||||
|
mockMenu.on.calls.forEach(function (call) {
|
||||||
|
if (call.args[0] === 'touchstart') {
|
||||||
|
// call.args[1]();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -75,6 +75,19 @@ define(
|
|||||||
mockDomainObject.calls
|
mockDomainObject.calls
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("mobile", function () {
|
||||||
|
mockQueryService.isMobile.andReturn(true);
|
||||||
|
gesture = new ContextMenuGesture(mockTimeout, mockQueryService, mockElement, mockDomainObject);
|
||||||
|
|
||||||
|
// Capture the contextmenu callback
|
||||||
|
fireGesture = mockElement.on.mostRecentCall.args[1];
|
||||||
|
|
||||||
|
expect(mockElement.on).toHaveBeenCalledWith(
|
||||||
|
"touchstart",
|
||||||
|
jasmine.any(Function)
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
Reference in New Issue
Block a user