-
Notifications
You must be signed in to change notification settings - Fork 6.7k
feat(tooltip): now can take the option for the close delay timeout #3576
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -365,6 +365,60 @@ describe('tooltip', function() { | |
})); | ||
}); | ||
|
||
describe('with specified popup close delay', function() { | ||
var $timeout; | ||
beforeEach(inject(function($compile, _$timeout_) { | ||
$timeout = _$timeout_; | ||
scope.delay = '1000'; | ||
elm = $compile(angular.element( | ||
'<span uib-tooltip="tooltip text" tooltip-popup-close-delay="{{delay}}" ng-disabled="disabled">Selector Text</span>' | ||
))(scope); | ||
elmScope = elm.scope(); | ||
tooltipScope = elmScope.$$childTail; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't using Angular's internal method If I understand it correctly, this is to access child scope, which we should try to avoid to.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've used the same setup as the test for the delay of the opening of the tooltip in the file, if you were to look at the rest of the spec it is doing the same. In a test, this is standard practice to access the directive's scope in order to check a value. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just a concern that came up, I know it works for now, but might be helpful for future reference. There might be a better way without depending so deeply on Angular's mechanics. |
||
scope.$digest(); | ||
})); | ||
|
||
it('should close after timeout', function() { | ||
trigger(elm, 'mouseenter'); | ||
expect(tooltipScope.isOpen).toBe(true); | ||
trigger(elm, 'mouseleave'); | ||
$timeout.flush(); | ||
expect(tooltipScope.isOpen).toBe(false); | ||
}); | ||
// | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete comment |
||
it('should use default popup close delay if specified delay is not a number and close after delay', function() { | ||
scope.delay = 'text1000'; | ||
scope.$digest(); | ||
trigger(elm, 'mouseenter'); | ||
expect(tooltipScope.popupCloseDelay).toBe(500); | ||
expect(tooltipScope.isOpen).toBe(true); | ||
trigger(elm, 'mouseleave'); | ||
$timeout.flush(); | ||
expect(tooltipScope.isOpen).toBe(false); | ||
}); | ||
|
||
it('should open when not disabled after being disabled and close after delay - issue #4204', function() { | ||
trigger(elm, 'mouseenter'); | ||
expect(tooltipScope.isOpen).toBe(true); | ||
|
||
elmScope.disabled = true; | ||
elmScope.$digest(); | ||
|
||
$timeout.flush(500); | ||
expect(tooltipScope.isOpen).toBe(false); | ||
|
||
elmScope.disabled = false; | ||
elmScope.$digest(); | ||
|
||
trigger(elm, 'mouseenter'); | ||
|
||
expect(tooltipScope.isOpen).toBe(true); | ||
trigger(elm, 'mouseleave'); | ||
$timeout.flush(); | ||
expect(tooltipScope.isOpen).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('with an is-open attribute', function() { | ||
beforeEach(inject(function ($compile) { | ||
scope.isOpen = false; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One dash