mirror of
https://github.com/nasa/openmct.git
synced 2025-06-15 21:58:13 +00:00
[Fixed Position] Add specs for drop
Add specs related to positioning of objects based on drop position, WTD-877.
This commit is contained in:
@ -157,6 +157,8 @@ define(
|
|||||||
|
|
||||||
// Position a panel after a drop event
|
// Position a panel after a drop event
|
||||||
function handleDrop(e, id, position) {
|
function handleDrop(e, id, position) {
|
||||||
|
// Ensure that configuration field is populated
|
||||||
|
$scope.configuration = $scope.configuration || {};
|
||||||
// Make sure there is a "elements" field in the
|
// Make sure there is a "elements" field in the
|
||||||
// view configuration.
|
// view configuration.
|
||||||
$scope.configuration.elements =
|
$scope.configuration.elements =
|
||||||
@ -173,6 +175,8 @@ define(
|
|||||||
if ($scope.commit) {
|
if ($scope.commit) {
|
||||||
$scope.commit("Dropped a frame.");
|
$scope.commit("Dropped a frame.");
|
||||||
}
|
}
|
||||||
|
// Populate template-facing position for this id
|
||||||
|
populatePosition(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Position panes when the model field changes
|
// Position panes when the model field changes
|
||||||
|
@ -84,6 +84,8 @@ define(
|
|||||||
|
|
||||||
// Position a panel after a drop event
|
// Position a panel after a drop event
|
||||||
function handleDrop(e, id, position) {
|
function handleDrop(e, id, position) {
|
||||||
|
// Ensure that configuration field is populated
|
||||||
|
$scope.configuration = $scope.configuration || {};
|
||||||
// Make sure there is a "panels" field in the
|
// Make sure there is a "panels" field in the
|
||||||
// view configuration.
|
// view configuration.
|
||||||
$scope.configuration.panels =
|
$scope.configuration.panels =
|
||||||
@ -100,6 +102,8 @@ define(
|
|||||||
if ($scope.commit) {
|
if ($scope.commit) {
|
||||||
$scope.commit("Dropped a frame.");
|
$scope.commit("Dropped a frame.");
|
||||||
}
|
}
|
||||||
|
// Populate template-facing position for this id
|
||||||
|
populatePosition(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Position panes when the model field changes
|
// Position panes when the model field changes
|
||||||
|
@ -27,6 +27,17 @@ define(
|
|||||||
return watch;
|
return watch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// As above, but for $on calls
|
||||||
|
function findOn(expr) {
|
||||||
|
var on;
|
||||||
|
mockScope.$on.calls.forEach(function (call) {
|
||||||
|
if (call.args[0] === expr) {
|
||||||
|
on = call.args[1];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return on;
|
||||||
|
}
|
||||||
|
|
||||||
function makeMockDomainObject(id) {
|
function makeMockDomainObject(id) {
|
||||||
var mockObject = jasmine.createSpyObj(
|
var mockObject = jasmine.createSpyObj(
|
||||||
'domainObject-' + id,
|
'domainObject-' + id,
|
||||||
@ -39,7 +50,7 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockScope = jasmine.createSpyObj(
|
mockScope = jasmine.createSpyObj(
|
||||||
'$scope',
|
'$scope',
|
||||||
[ "$on", "$watch" ]
|
[ "$on", "$watch", "commit" ]
|
||||||
);
|
);
|
||||||
mockSubscriber = jasmine.createSpyObj(
|
mockSubscriber = jasmine.createSpyObj(
|
||||||
'telemetrySubscriber',
|
'telemetrySubscriber',
|
||||||
@ -157,6 +168,33 @@ define(
|
|||||||
controller.setBounds(s2);
|
controller.setBounds(s2);
|
||||||
expect(controller.getCellStyles().length).toEqual(60); // 10 * 6
|
expect(controller.getCellStyles().length).toEqual(60); // 10 * 6
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("listens for drop events", function () {
|
||||||
|
// Layout should position panels according to
|
||||||
|
// where the user dropped them, so it needs to
|
||||||
|
// listen for drop events.
|
||||||
|
expect(mockScope.$on).toHaveBeenCalledWith(
|
||||||
|
'mctDrop',
|
||||||
|
jasmine.any(Function)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Verify precondition
|
||||||
|
expect(controller.getStyle('d')).not.toBeDefined();
|
||||||
|
|
||||||
|
// Notify that a drop occurred
|
||||||
|
testModel.composition.push('d');
|
||||||
|
findOn('mctDrop')(
|
||||||
|
{},
|
||||||
|
'd',
|
||||||
|
{ x: 300, y: 100 }
|
||||||
|
);
|
||||||
|
expect(controller.getStyle('d')).toBeDefined();
|
||||||
|
|
||||||
|
// Should have triggered commit (provided by
|
||||||
|
// EditRepresenter) with some message.
|
||||||
|
expect(mockScope.commit)
|
||||||
|
.toHaveBeenCalledWith(jasmine.any(String));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
@ -14,7 +14,7 @@ define(
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockScope = jasmine.createSpyObj(
|
mockScope = jasmine.createSpyObj(
|
||||||
"$scope",
|
"$scope",
|
||||||
[ "$watch" ]
|
[ "$watch", "$on", "commit" ]
|
||||||
);
|
);
|
||||||
|
|
||||||
testModel = {
|
testModel = {
|
||||||
@ -97,9 +97,6 @@ define(
|
|||||||
// Populate scope
|
// Populate scope
|
||||||
mockScope.$watch.mostRecentCall.args[1](testModel.composition);
|
mockScope.$watch.mostRecentCall.args[1](testModel.composition);
|
||||||
|
|
||||||
// Add a commit method to scope
|
|
||||||
mockScope.commit = jasmine.createSpy("commit");
|
|
||||||
|
|
||||||
// Do a drag
|
// Do a drag
|
||||||
controller.startDrag("b", [1, 1], [0, 0]);
|
controller.startDrag("b", [1, 1], [0, 0]);
|
||||||
controller.continueDrag([100, 100]);
|
controller.continueDrag([100, 100]);
|
||||||
@ -110,6 +107,33 @@ define(
|
|||||||
expect(mockScope.commit)
|
expect(mockScope.commit)
|
||||||
.toHaveBeenCalledWith(jasmine.any(String));
|
.toHaveBeenCalledWith(jasmine.any(String));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("listens for drop events", function () {
|
||||||
|
// Layout should position panels according to
|
||||||
|
// where the user dropped them, so it needs to
|
||||||
|
// listen for drop events.
|
||||||
|
expect(mockScope.$on).toHaveBeenCalledWith(
|
||||||
|
'mctDrop',
|
||||||
|
jasmine.any(Function)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Verify precondition
|
||||||
|
expect(testConfiguration.panels.d).not.toBeDefined();
|
||||||
|
|
||||||
|
// Notify that a drop occurred
|
||||||
|
testModel.composition.push('d');
|
||||||
|
mockScope.$on.mostRecentCall.args[1](
|
||||||
|
{},
|
||||||
|
'd',
|
||||||
|
{ x: 300, y: 100 }
|
||||||
|
);
|
||||||
|
expect(testConfiguration.panels.d).toBeDefined();
|
||||||
|
|
||||||
|
// Should have triggered commit (provided by
|
||||||
|
// EditRepresenter) with some message.
|
||||||
|
expect(mockScope.commit)
|
||||||
|
.toHaveBeenCalledWith(jasmine.any(String));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
Reference in New Issue
Block a user