[Mobile] Tests

ContextMenu and InfoButton Gesture
tests remain.
This commit is contained in:
Shivam Dave 2015-08-05 12:14:16 -07:00
parent f46a0853b9
commit 0b635afcf7
3 changed files with 21 additions and 7 deletions

View File

@ -27,12 +27,14 @@ define(
"use strict"; "use strict";
describe("The info button gesture", function () { describe("The info button gesture", function () {
var mockDocument, var mockTimeout,
mockDocument,
mockAgentService, mockAgentService,
mockInfoService, mockInfoService,
testDelay = 12321, testDelay = 12321,
mockElement, mockElement,
mockDomainObject, mockDomainObject,
mockEvent,
mockScope, mockScope,
mockOff, mockOff,
testMetadata, testMetadata,
@ -40,7 +42,16 @@ define(
mockHide, mockHide,
gesture; gesture;
function fireEvent(evt, value) {
mockElement.on.calls.forEach(function (call) {
if (call.args[0] === evt) {
call.args[1](value);
}
});
}
beforeEach(function () { beforeEach(function () {
mockTimeout = jasmine.createSpy('$timeout');
mockDocument = jasmine.createSpyObj('$document', ['find']); mockDocument = jasmine.createSpyObj('$document', ['find']);
mockAgentService = jasmine.createSpyObj('agentService', ['isMobile', 'isPhone']); mockAgentService = jasmine.createSpyObj('agentService', ['isMobile', 'isPhone']);
mockInfoService = jasmine.createSpyObj( mockInfoService = jasmine.createSpyObj(
@ -63,13 +74,15 @@ define(
); );
mockElement = jasmine.createSpyObj( mockElement = jasmine.createSpyObj(
'element', 'element',
[ 'on', 'off', 'scope', 'css' ] [ 'on', 'off', 'scope', 'css', 'click' ]
); );
mockDomainObject = jasmine.createSpyObj( mockDomainObject = jasmine.createSpyObj(
'domainObject', 'domainObject',
[ 'getId', 'getCapability', 'useCapability', 'getModel' ] [ 'getId', 'getCapability', 'useCapability', 'getModel' ]
); );
mockEvent = jasmine.createSpyObj("event", ["preventDefault", "stopPropagation"]);
mockEvent.pageX = 0;
mockEvent.pageY = 0;
mockScope = jasmine.createSpyObj('$scope', [ '$on' ]); mockScope = jasmine.createSpyObj('$scope', [ '$on' ]);
mockOff = jasmine.createSpy('$off'); mockOff = jasmine.createSpy('$off');
testMetadata = [ { name: "Test name", value: "Test value" } ]; testMetadata = [ { name: "Test name", value: "Test value" } ];
@ -92,11 +105,12 @@ define(
); );
}); });
it("listens for click on the representation", function () { it("expect click on the representation", function () {
expect(mockElement.on) expect(mockElement.on)
.toHaveBeenCalledWith('click', jasmine.any(Function)); .toHaveBeenCalledWith('click', jasmine.any(Function));
}); });
}); });
} }
); );

View File

@ -138,7 +138,7 @@ define(
mockAgentService mockAgentService
); );
service.display('', '', {}, [0, 0]); service.display('', '', {}, [0, 0]);
}); });
}); });
}); });

View File

@ -166,7 +166,7 @@ define(
expect(mockBody.off).not.toHaveBeenCalled(); expect(mockBody.off).not.toHaveBeenCalled();
}); });
it("mobile", function () { it("keeps a menu when menu is clicked on mobile", function () {
mockAgentService.isMobile.andReturn(true); mockAgentService.isMobile.andReturn(true);
action = new ContextMenuAction( action = new ContextMenuAction(
mockCompile, mockCompile,