2015-05-13 23:42:35 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
|
|
|
* as represented by the Administrator of the National Aeronautics and Space
|
|
|
|
* Administration. All rights reserved.
|
|
|
|
*
|
|
|
|
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*
|
|
|
|
* Open MCT Web includes source code licensed under additional open source
|
|
|
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
|
|
|
* this source code distribution or the Licensing information page available
|
|
|
|
* at runtime from the About dialog for additional information.
|
|
|
|
*****************************************************************************/
|
2014-11-22 18:11:06 +00:00
|
|
|
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
|
|
|
|
|
2014-11-22 17:36:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Module defining ContextMenuGestureSpec. Created by vwoeltje on 11/22/14.
|
|
|
|
*/
|
|
|
|
define(
|
2015-07-02 19:50:48 +00:00
|
|
|
["../../src/gestures/ContextMenuGesture"],
|
|
|
|
function (ContextMenuGesture) {
|
2014-11-22 17:36:30 +00:00
|
|
|
"use strict";
|
|
|
|
|
2014-11-22 18:11:06 +00:00
|
|
|
var JQLITE_FUNCTIONS = [ "on", "off", "find", "append", "remove" ],
|
2015-07-02 21:00:54 +00:00
|
|
|
DOMAIN_OBJECT_METHODS = [ "getId", "getModel", "getCapability", "hasCapability", "useCapability" ];
|
2014-11-22 18:11:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
describe("The 'context menu' gesture", function () {
|
2015-07-29 17:00:03 +00:00
|
|
|
var mockTimeout,
|
|
|
|
mockElement,
|
2015-07-23 23:55:45 +00:00
|
|
|
mockQueryService,
|
2014-11-22 18:11:06 +00:00
|
|
|
mockDomainObject,
|
|
|
|
mockEvent,
|
|
|
|
gesture,
|
|
|
|
fireGesture;
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
mockElement = jasmine.createSpyObj("element", JQLITE_FUNCTIONS);
|
2015-07-29 17:00:03 +00:00
|
|
|
mockTimeout = jasmine.createSpy("$timeout");
|
|
|
|
mockQueryService = jasmine.createSpyObj("queryService", ["isMobile"]);
|
2014-11-22 18:11:06 +00:00
|
|
|
mockDomainObject = jasmine.createSpyObj("domainObject", DOMAIN_OBJECT_METHODS);
|
|
|
|
mockEvent = jasmine.createSpyObj("event", ["preventDefault"]);
|
2015-07-27 22:21:59 +00:00
|
|
|
mockQueryService = jasmine.createSpyObj("queryService", ["isMobile"]);
|
2015-07-23 23:55:45 +00:00
|
|
|
|
2015-07-29 17:00:03 +00:00
|
|
|
gesture = new ContextMenuGesture(mockTimeout, mockQueryService, mockElement, mockDomainObject);
|
2014-11-22 18:11:06 +00:00
|
|
|
|
|
|
|
// Capture the contextmenu callback
|
|
|
|
fireGesture = mockElement.on.mostRecentCall.args[1];
|
|
|
|
});
|
|
|
|
|
|
|
|
it("attaches a callback for context menu events", function () {
|
|
|
|
expect(mockElement.on).toHaveBeenCalledWith(
|
|
|
|
"contextmenu",
|
|
|
|
jasmine.any(Function)
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("detaches a callback for context menu events when destroyed", function () {
|
|
|
|
expect(mockElement.off).not.toHaveBeenCalled();
|
|
|
|
|
|
|
|
gesture.destroy();
|
|
|
|
|
|
|
|
expect(mockElement.off).toHaveBeenCalledWith(
|
|
|
|
"contextmenu",
|
2015-07-02 21:00:54 +00:00
|
|
|
//mockElement.on.mostRecentCall.args[1]
|
|
|
|
mockDomainObject.calls
|
2014-11-22 18:11:06 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
2014-11-22 17:36:30 +00:00
|
|
|
}
|
|
|
|
);
|