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

Commit

Permalink
chore(tooltip): unify code style
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleycho committed Aug 11, 2015
1 parent 20f525b commit f3b68b3
Show file tree
Hide file tree
Showing 4 changed files with 299 additions and 339 deletions.
29 changes: 14 additions & 15 deletions src/tooltip/test/tooltip-template.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('tooltip template', function() {
// load the template
beforeEach(module('template/tooltip/tooltip-template-popup.html'));

beforeEach(inject(function ($templateCache) {
beforeEach(inject(function($templateCache) {
$templateCache.put('myUrl', [200, '<span>{{ myTemplateText }}</span>', {}]);
}));

Expand All @@ -31,7 +31,7 @@ describe('tooltip template', function() {
}));

it('should open on mouseenter', inject(function() {
elm.trigger( 'mouseenter' );
elm.trigger('mouseenter');
expect( tooltipScope.isOpen ).toBe( true );

expect( elmBody.children().length ).toBe( 2 );
Expand All @@ -41,39 +41,38 @@ describe('tooltip template', function() {
scope.templateUrl = null;
scope.$digest();

elm.trigger( 'mouseenter' );
expect( tooltipScope.isOpen ).toBe( false );
elm.trigger('mouseenter');
expect(tooltipScope.isOpen).toBe(false);

expect( elmBody.children().length ).toBe( 1 );
expect(elmBody.children().length).toBe(1);
}));

it('should show updated text', inject(function() {
scope.myTemplateText = 'some text';
scope.$digest();

elm.trigger( 'mouseenter' );
expect( tooltipScope.isOpen ).toBe( true );
elm.trigger('mouseenter');
expect(tooltipScope.isOpen).toBe(true);

expect( elmBody.children().eq(1).text().trim() ).toBe( 'some text' );
expect(elmBody.children().eq(1).text().trim()).toBe('some text');

scope.myTemplateText = 'new text';
scope.$digest();

expect( elmBody.children().eq(1).text().trim() ).toBe( 'new text' );
expect(elmBody.children().eq(1).text().trim()).toBe('new text');
}));

it('should hide tooltip when template becomes empty', inject(function ($timeout) {
elm.trigger( 'mouseenter' );
expect( tooltipScope.isOpen ).toBe( true );
it('should hide tooltip when template becomes empty', inject(function($timeout) {
elm.trigger('mouseenter');
expect(tooltipScope.isOpen).toBe(true);

scope.templateUrl = '';
scope.$digest();

expect( tooltipScope.isOpen ).toBe( false );
expect(tooltipScope.isOpen).toBe(false);

$timeout.flush();
expect( elmBody.children().length ).toBe( 1 );
expect(elmBody.children().length).toBe(1);
}));

});

Loading

0 comments on commit f3b68b3

Please sign in to comment.