Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 3627e9c

Browse files
chrisirhcpkozlowski-opensource
authored andcommitted
test(tooltip): check scope after hiding and showing
Isolate scope contents should be the same after hiding and showing the tooltip. The isolate scope's parent should also always be set to the directive's scope correctly. Reproduces #1191
1 parent f56a396 commit 3627e9c

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

Diff for: src/tooltip/test/tooltip.spec.js

+26-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe('tooltip', function() {
9898
scope.alt = "Alt Message";
9999

100100
elmBody = $compile( angular.element(
101-
'<div><span alt={{alt}} tooltip="{{tooltipMsg}}">Selector Text</span></div>'
101+
'<div><span alt={{alt}} tooltip="{{tooltipMsg}}" tooltip-animation="false">Selector Text</span></div>'
102102
) )( scope );
103103

104104
$compile( elmBody )( scope );
@@ -114,6 +114,13 @@ describe('tooltip', function() {
114114
expect( ttScope.content ).toBe( scope.tooltipMsg );
115115

116116
elm.trigger( 'mouseleave' );
117+
118+
//Isolate scope contents should be the same after hiding and showing again (issue 1191)
119+
elm.trigger( 'mouseenter' );
120+
121+
ttScope = angular.element( elmBody.children()[1] ).scope();
122+
expect( ttScope.placement ).toBe( 'top' );
123+
expect( ttScope.content ).toBe( scope.tooltipMsg );
117124
}));
118125

119126
it('should not show tooltips if there is nothing to show - issue #129', inject(function ($compile) {
@@ -136,6 +143,24 @@ describe('tooltip', function() {
136143
expect( elmBody.children().length ).toBe( 0 );
137144
}));
138145

146+
it('issue 1191 - isolate scope on the popup should always be child of correct element scope', inject( function ( $compile ) {
147+
var ttScope;
148+
elm.trigger( 'mouseenter' );
149+
150+
ttScope = angular.element( elmBody.children()[1] ).scope();
151+
expect( ttScope.$parent ).toBe( elmScope );
152+
153+
elm.trigger( 'mouseleave' );
154+
155+
// After leaving and coming back, the scope's parent should be the same
156+
elm.trigger( 'mouseenter' );
157+
158+
ttScope = angular.element( elmBody.children()[1] ).scope();
159+
expect( ttScope.$parent ).toBe( elmScope );
160+
161+
elm.trigger( 'mouseleave' );
162+
}));
163+
139164
describe('with specified enable expression', function() {
140165

141166
beforeEach(inject(function ($compile) {

0 commit comments

Comments
 (0)