[Toolbar] set selection initially in fixed controller and toolbar... (#1994)
* [Toolbar] set selection initially in fixed controller and toolbar... ... to make the add button appear in the toolbar when a fixed position is created. Remove selection change listener on destroy. Start a digest cycle when handling selection in toolbar to avoid delays in toolbar. Fixes #1991, #1987 * fixed checkstyle and lint errors * Fix tests * Update comment
This commit is contained in:
committed by
Pete Richards
parent
78a5ace18d
commit
75ae5ab3bb
@@ -36,7 +36,7 @@ define(
|
||||
beforeEach(function () {
|
||||
mockScope = jasmine.createSpyObj(
|
||||
'$scope',
|
||||
['$on', '$watch', '$watchCollection', "commit"]
|
||||
['$on', '$watch', '$watchCollection', "commit", "$apply"]
|
||||
);
|
||||
mockElement = {};
|
||||
testAttrs = { toolbar: 'testToolbar' };
|
||||
|
||||
@@ -30,7 +30,8 @@ define(
|
||||
otherElement,
|
||||
selection,
|
||||
mockSelection,
|
||||
mockOpenMCT;
|
||||
mockOpenMCT,
|
||||
mockScope;
|
||||
|
||||
beforeEach(function () {
|
||||
testProxy = { someKey: "some value" };
|
||||
@@ -46,7 +47,12 @@ define(
|
||||
mockOpenMCT = {
|
||||
selection: mockSelection
|
||||
};
|
||||
selection = new EditToolbarSelection(mockOpenMCT);
|
||||
mockScope = jasmine.createSpyObj('$scope', [
|
||||
'$on',
|
||||
'$apply'
|
||||
]);
|
||||
|
||||
selection = new EditToolbarSelection(mockScope, mockOpenMCT);
|
||||
selection.proxy(testProxy);
|
||||
});
|
||||
|
||||
@@ -103,6 +109,20 @@ define(
|
||||
expect(selection.all()).toEqual([testProxy]);
|
||||
});
|
||||
|
||||
it("cleans up selection on scope destroy", function () {
|
||||
expect(mockScope.$on).toHaveBeenCalledWith(
|
||||
'$destroy',
|
||||
jasmine.any(Function)
|
||||
);
|
||||
|
||||
mockScope.$on.mostRecentCall.args[1]();
|
||||
|
||||
expect(mockOpenMCT.selection.off).toHaveBeenCalledWith(
|
||||
'change',
|
||||
jasmine.any(Function)
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user