[Fixed Position] Update FixedController spec
Update FixedController spec to include test for updating set of elements in configuration based on changes to composition, WTD-883.
This commit is contained in:
@@ -13,6 +13,7 @@ define(
|
|||||||
mockFormatter,
|
mockFormatter,
|
||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
mockSubscription,
|
mockSubscription,
|
||||||
|
mockPromise,
|
||||||
testGrid,
|
testGrid,
|
||||||
testModel,
|
testModel,
|
||||||
testValues,
|
testValues,
|
||||||
@@ -77,6 +78,10 @@ define(
|
|||||||
'subscription',
|
'subscription',
|
||||||
[ 'unsubscribe', 'getTelemetryObjects', 'getRangeValue' ]
|
[ 'unsubscribe', 'getTelemetryObjects', 'getRangeValue' ]
|
||||||
);
|
);
|
||||||
|
mockPromise = jasmine.createSpyObj(
|
||||||
|
'promise',
|
||||||
|
[ 'then' ]
|
||||||
|
);
|
||||||
|
|
||||||
testGrid = [ 123, 456 ];
|
testGrid = [ 123, 456 ];
|
||||||
testModel = {
|
testModel = {
|
||||||
@@ -103,6 +108,8 @@ define(
|
|||||||
mockScope.model = testModel;
|
mockScope.model = testModel;
|
||||||
mockScope.configuration = testConfiguration;
|
mockScope.configuration = testConfiguration;
|
||||||
mockScope.selection = []; // Act like edit mode
|
mockScope.selection = []; // Act like edit mode
|
||||||
|
mockQ.when.andReturn(mockPromise);
|
||||||
|
mockPromise.then.andCallFake(function (cb) { cb({}); });
|
||||||
|
|
||||||
controller = new FixedController(
|
controller = new FixedController(
|
||||||
mockScope,
|
mockScope,
|
||||||
@@ -363,6 +370,19 @@ define(
|
|||||||
// Style should have been updated
|
// Style should have been updated
|
||||||
expect(controller.selected().style).not.toEqual(oldStyle);
|
expect(controller.selected().style).not.toEqual(oldStyle);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("ensures elements in view match elements in composition", function () {
|
||||||
|
// View should ensure that at least one element is present
|
||||||
|
// for each id, and then unused ids do not have elements.
|
||||||
|
mockScope.model = testModel;
|
||||||
|
testModel.composition = [ 'b', 'd' ];
|
||||||
|
findWatch("model.composition")(mockScope.model.composition);
|
||||||
|
|
||||||
|
// Should have a new element for d; should not have elements for a, c
|
||||||
|
expect(testConfiguration.elements.length).toEqual(2);
|
||||||
|
expect(testConfiguration.elements[0].id).toEqual('b');
|
||||||
|
expect(testConfiguration.elements[1].id).toEqual('d');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
Reference in New Issue
Block a user