Skip to content

Commit 099a774

Browse files
committed
tests(style): header how should be offscreen yet visible
1 parent 31b65bb commit 099a774

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = function(config) {
2121
'bower_components/bootstrap/dist/css/bootstrap.css',
2222
'src/**/*.js',
2323
'src/**/*.css',
24-
'tests/**/*.spec.js'
24+
'tests/**/*.js'
2525
],
2626

2727

tests/directive.spec.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,43 @@ describe('directive', function () {
1111
$rootScope = _$rootScope_;
1212
}));
1313

14+
it('header rows are visible but offscreen', function () {
15+
var markup = [
16+
'<table wt-responsive-table>',
17+
' <thead>',
18+
' <tr>',
19+
' <th>First title</th>',
20+
' <th>Second title</th>',
21+
' <th>Third title</th>',
22+
' <th>Forth title</th>',
23+
' </tr>',
24+
' </thead>',
25+
' <tbody>',
26+
' <tr>',
27+
' <td>First column</td>',
28+
' <td>Second column</td>',
29+
' <td>Third column</td>',
30+
' <td>Forth column</td>',
31+
' </tr>',
32+
' <tr>',
33+
' <td>First column</td>',
34+
' <td>Second column</td>',
35+
' <td>Third column</td>',
36+
' <td>Forth column</td>',
37+
' </tr>',
38+
' </tbody>',
39+
'</table>'
40+
].join('');
41+
var element = angular.element(markup);
42+
document.body.appendChild(element[0]);
43+
$compile(element);
44+
$rootScope.$digest();
45+
46+
var headerRow = element.find('tr th');
47+
expect(headerRow.is(':visible')).toBe(true);
48+
expect(headerRow.is(':offscreen')).toBe(true);
49+
});
50+
1451
it('supports rows with no <thead>', function () {
1552
var markup = [
1653
'<table wt-responsive-table>',
@@ -43,7 +80,6 @@ describe('directive', function () {
4380
expect(headerRow.eq(1).attr('data-title')).toBeUndefined();
4481
expect(headerRow.eq(2).attr('data-title')).toBeUndefined();
4582
expect(headerRow.eq(3).attr('data-title')).toBeUndefined();
46-
expect(headerRow.is(':visible')).toBe(true);
4783
});
4884

4985
it('supports colspan', function () {

tests/lib.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path="../typings/jquery/jquery.d.ts"/>
2+
jQuery.expr.filters.offscreen = function(el) {
3+
//console.log('el(' + el.textContent + '): (' + el.offsetLeft + ' x ' + el.offsetTop + ') -> (' + (el.offsetLeft+el.offsetWidth) + ' x ' + (el.offsetTop+el.offsetHeight) + ')');
4+
return (
5+
(el.offsetLeft + el.offsetWidth) < 0
6+
|| (el.offsetTop + el.offsetHeight) < 0
7+
|| (el.offsetLeft > window.innerWidth || el.offsetTop > window.innerHeight)
8+
);
9+
};

0 commit comments

Comments
 (0)