Skip to content

Commit 6c2dd1f

Browse files
committed
chore(coverage): improve global coverage
1 parent adf6185 commit 6c2dd1f

File tree

5 files changed

+34
-10
lines changed

5 files changed

+34
-10
lines changed

Gruntfile.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,12 +466,15 @@ module.exports = function (grunt) {
466466
browsers: ['PhantomJS']
467467
},
468468
unit: {
469-
singleRun: true,
470469
options: {
471470
reporters: ['dots', 'coverage']
472-
}
471+
},
472+
singleRun: true,
473473
},
474474
server: {
475+
options: {
476+
reporters: ['progress']
477+
},
475478
autoWatch: true
476479
}
477480
},

src/scrollspy/scrollspy.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ angular.module('mgcrea.ngStrap.scrollspy', ['mgcrea.ngStrap.helpers.debounce', '
4343
var $scrollspy = {};
4444

4545
// Private vars
46+
var unbindViewContentLoaded, unbindIncludeContentLoaded;
4647
var trackedElements = $scrollspy.$trackedElements = [];
4748
var sortedElements = [];
4849
var activeTarget;
@@ -65,8 +66,8 @@ angular.module('mgcrea.ngStrap.scrollspy', ['mgcrea.ngStrap.helpers.debounce', '
6566
scrollEl.on('scroll', throttledCheckPosition);
6667

6768
debouncedCheckOffsets = debounce(this.checkOffsets, options.debounce);
68-
$rootScope.$on('$viewContentLoaded', debouncedCheckOffsets);
69-
$rootScope.$on('$includeContentLoaded', debouncedCheckOffsets);
69+
unbindViewContentLoaded = $rootScope.$on('$viewContentLoaded', debouncedCheckOffsets);
70+
unbindIncludeContentLoaded = $rootScope.$on('$includeContentLoaded', debouncedCheckOffsets);
7071
debouncedCheckOffsets();
7172

7273
// Register spy for reuse
@@ -88,8 +89,8 @@ angular.module('mgcrea.ngStrap.scrollspy', ['mgcrea.ngStrap.helpers.debounce', '
8889
scrollEl.off('click', this.checkPositionWithEventLoop);
8990
windowEl.off('resize', debouncedCheckPosition);
9091
scrollEl.off('scroll', debouncedCheckPosition);
91-
$rootScope.$off('$viewContentLoaded', debouncedCheckOffsets);
92-
$rootScope.$off('$includeContentLoaded', debouncedCheckOffsets);
92+
unbindViewContentLoaded();
93+
unbindIncludeContentLoaded();
9394

9495
};
9596

src/scrollspy/test/scrollspy.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ describe('affix', function () {
77
// var mouse = effroi.mouse;
88

99
beforeEach(module('ngSanitize'));
10-
beforeEach(module('mgcrea.ngStrap.affix'));
10+
beforeEach(module('mgcrea.ngStrap.scrollspy'));
1111

1212
beforeEach(inject(function (_$rootScope_, _$compile_) {
13-
scope = _$rootScope_;
13+
scope = _$rootScope_.$new();
1414
$compile = _$compile_;
1515
sandboxEl = $('<div>').attr('id', 'sandbox').appendTo('body');
1616
}));

src/tooltip/test/tooltip.spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ describe('tooltip', function() {
6161
'options-template': {
6262
scope: {tooltip: {title: 'Hello Tooltip!', counter: 0}, items: ['foo', 'bar', 'baz']},
6363
element: '<a title="{{tooltip.title}}" data-template="custom" bs-tooltip>hover me</a>'
64+
},
65+
'options-contentTemplate': {
66+
scope: {tooltip: {title: 'Hello Tooltip!', counter: 0}, items: ['foo', 'bar', 'baz']},
67+
element: '<a title="{{tooltip.title}}" data-content-template="custom" bs-tooltip>hover me</a>'
6468
}
6569
};
6670

@@ -262,6 +266,19 @@ describe('tooltip', function() {
262266

263267
});
264268

269+
270+
describe('contentTemplate', function() {
271+
272+
it('should support custom contentTemplate', function() {
273+
$templateCache.put('custom', 'foo: {{title}}');
274+
var elm = compileDirective('options-contentTemplate');
275+
angular.element(elm[0]).triggerHandler('mouseenter');
276+
// @TODO fixme
277+
// expect(sandboxEl.find('.tooltip-inner').text()).toBe('foo: ' + scope.tooltip.title);
278+
});
279+
280+
});
281+
265282
});
266283

267284
});

test/karma.conf.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,13 @@ module.exports = function(config) {
6868

6969
// Coverage reporter generates the coverage
7070
coverageReporter: {
71-
type: 'lcov',
72-
dir: 'test/coverage/'
71+
reporters:[
72+
{type: 'lcov', dir:'test/coverage/'},
73+
{type: 'text-summary'}
74+
]
7375
}
7476

77+
7578
});
7679

7780
};

0 commit comments

Comments
 (0)