mirror of
https://github.com/nasa/openmct.git
synced 2024-12-26 00:01:05 +00:00
Merge remote-tracking branch 'github-open/open19' into open-master
This commit is contained in:
commit
2040304980
@ -74,6 +74,7 @@ define(
|
|||||||
lastBounds.width !== bounds.width ||
|
lastBounds.width !== bounds.width ||
|
||||||
lastBounds.height !== bounds.height) {
|
lastBounds.height !== bounds.height) {
|
||||||
scope.$eval(attrs.mctResize, { bounds: bounds });
|
scope.$eval(attrs.mctResize, { bounds: bounds });
|
||||||
|
scope.$apply(); // Trigger a digest
|
||||||
lastBounds = bounds;
|
lastBounds = bounds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,7 +87,7 @@ define(
|
|||||||
height: element[0].offsetHeight
|
height: element[0].offsetHeight
|
||||||
});
|
});
|
||||||
if (active) {
|
if (active) {
|
||||||
$timeout(onInterval, currentInterval());
|
$timeout(onInterval, currentInterval(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ define(
|
|||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockTimeout = jasmine.createSpy("$timeout");
|
mockTimeout = jasmine.createSpy("$timeout");
|
||||||
mockScope = jasmine.createSpyObj("$scope", ["$eval", "$on"]);
|
mockScope = jasmine.createSpyObj("$scope", ["$eval", "$on", "$apply"]);
|
||||||
|
|
||||||
testElement = { offsetWidth: 100, offsetHeight: 200 };
|
testElement = { offsetWidth: 100, offsetHeight: 200 };
|
||||||
testAttrs = { mctResize: "some-expr" };
|
testAttrs = { mctResize: "some-expr" };
|
||||||
@ -52,7 +52,8 @@ define(
|
|||||||
mctResize.link(mockScope, [testElement], testAttrs);
|
mctResize.link(mockScope, [testElement], testAttrs);
|
||||||
expect(mockTimeout).toHaveBeenCalledWith(
|
expect(mockTimeout).toHaveBeenCalledWith(
|
||||||
jasmine.any(Function),
|
jasmine.any(Function),
|
||||||
jasmine.any(Number)
|
jasmine.any(Number),
|
||||||
|
false
|
||||||
);
|
);
|
||||||
expect(mockScope.$eval).toHaveBeenCalledWith(
|
expect(mockScope.$eval).toHaveBeenCalledWith(
|
||||||
testAttrs.mctResize,
|
testAttrs.mctResize,
|
||||||
@ -110,6 +111,35 @@ define(
|
|||||||
expect(mockTimeout.calls.length).toEqual(2);
|
expect(mockTimeout.calls.length).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("triggers a digest cycle when size changes", function () {
|
||||||
|
var applyCount;
|
||||||
|
mctResize.link(mockScope, [testElement], testAttrs);
|
||||||
|
applyCount = mockScope.$apply.calls.length;
|
||||||
|
|
||||||
|
// Change the element's apparent size
|
||||||
|
testElement.offsetWidth = 300;
|
||||||
|
testElement.offsetHeight = 350;
|
||||||
|
|
||||||
|
// Fire the timeout
|
||||||
|
mockTimeout.mostRecentCall.args[0]();
|
||||||
|
|
||||||
|
// No more apply calls
|
||||||
|
expect(mockScope.$apply.calls.length)
|
||||||
|
.toBeGreaterThan(applyCount);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not trigger a digest cycle when size does not change", function () {
|
||||||
|
var applyCount;
|
||||||
|
mctResize.link(mockScope, [testElement], testAttrs);
|
||||||
|
applyCount = mockScope.$apply.calls.length;
|
||||||
|
|
||||||
|
// Fire the timeout
|
||||||
|
mockTimeout.mostRecentCall.args[0]();
|
||||||
|
|
||||||
|
// No more apply calls
|
||||||
|
expect(mockScope.$apply.calls.length).toEqual(applyCount);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
Loading…
Reference in New Issue
Block a user