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

Commit 3984e67

Browse files
committed
Fix header tests for IE8
1 parent be31d9e commit 3984e67

1 file changed

Lines changed: 45 additions & 6 deletions

File tree

test/header.js

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,21 @@ describe("A HeaderRow", function () {
287287

288288
it("renders a row of header cells", function () {
289289
expect(row.$el[0].tagName).toBe("TR");
290-
expect(row.$el[0].innerHTML).toBe('<th class="editable sortable renderable name"><a>name<b class="sort-caret"></b></a></th>' +
291-
'<th class="editable sortable renderable year"><a>year<b class="sort-caret"></b></a></th>');
290+
var th1 = $(row.el.childNodes[0]);
291+
expect(th1.hasClass("editable")).toBe(true);
292+
expect(th1.hasClass("sortable")).toBe(true);
293+
expect(th1.hasClass("renderable")).toBe(true);
294+
expect(th1.hasClass("name")).toBe(true);
295+
expect(th1.find("a").text()).toBe("name");
296+
expect(th1.find("a").eq(1).is($("b", {className: "sort-caret"})));
297+
298+
var th2 = $(row.el.childNodes[1]);
299+
expect(th2.hasClass("editable")).toBe(true);
300+
expect(th2.hasClass("sortable")).toBe(true);
301+
expect(th2.hasClass("renderable")).toBe(true);
302+
expect(th2.hasClass("year")).toBe(true);
303+
expect(th2.find("a").text()).toBe("year");
304+
expect(th2.find("a > b:last-child").eq(0).hasClass("sort-caret")).toBe(true);
292305
});
293306

294307
it("resets the carets of the non-sorting columns", function () {
@@ -301,7 +314,13 @@ describe("A HeaderRow", function () {
301314
it("inserts or removes a cell if a column is added or removed", function () {
302315
row.columns.add({name: "price", cell: "number"});
303316
expect(row.$el.children().length).toBe(3);
304-
expect(row.$el.children().last()[0].outerHTML).toBe('<th class="editable sortable renderable price"><a>price<b class="sort-caret"></b></a></th>');
317+
var lastTh = $(row.el.lastChild);
318+
expect(lastTh.hasClass("editable")).toBe(true);
319+
expect(lastTh.hasClass("sortable")).toBe(true);
320+
expect(lastTh.hasClass("renderable")).toBe(true);
321+
expect(lastTh.hasClass("price")).toBe(true);
322+
expect(lastTh.find("a").text()).toBe("price");
323+
expect(lastTh.find("a > b:last-child").eq(0).hasClass("sort-caret")).toBe(true);
305324

306325
row.columns.add({name: "publisher", cell: "string", renderable: false});
307326
expect(row.$el.children().length).toBe(4);
@@ -310,7 +329,13 @@ describe("A HeaderRow", function () {
310329

311330
row.columns.remove(row.columns.first());
312331
expect(row.$el.children().length).toBe(3);
313-
expect(row.$el.children().first()[0].outerHTML).toBe('<th class="editable sortable renderable year"><a>year<b class="sort-caret"></b></a></th>');
332+
var firstTh = $(row.el.firstChild);
333+
expect(firstTh.hasClass("editable")).toBe(true);
334+
expect(firstTh.hasClass("sortable")).toBe(true);
335+
expect(firstTh.hasClass("renderable")).toBe(true);
336+
expect(firstTh.hasClass("year")).toBe(true);
337+
expect(firstTh.find("a").text()).toBe("year");
338+
expect(firstTh.find("a > b:last-child").eq(0).hasClass("sort-caret")).toBe(true);
314339
});
315340

316341
});
@@ -355,8 +380,22 @@ describe("A Header", function () {
355380

356381
it("renders a header with a row of header cells", function () {
357382
expect(head.$el[0].tagName).toBe("THEAD");
358-
expect(head.$el[0].innerHTML).toBe('<tr><th class="editable sortable renderable name"><a>name<b class="sort-caret"></b></a></th>' +
359-
'<th class="editable sortable renderable year"><a>year<b class="sort-caret"></b></a></th></tr>');
383+
384+
var th1 = $(head.row.el.childNodes[0]);
385+
expect(th1.hasClass("editable")).toBe(true);
386+
expect(th1.hasClass("sortable")).toBe(true);
387+
expect(th1.hasClass("renderable")).toBe(true);
388+
expect(th1.hasClass("name")).toBe(true);
389+
expect(th1.find("a").text()).toBe("name");
390+
expect(th1.find("a").eq(1).is($("b", {className: "sort-caret"})));
391+
392+
var th2 = $(head.row.el.childNodes[1]);
393+
expect(th2.hasClass("editable")).toBe(true);
394+
expect(th2.hasClass("sortable")).toBe(true);
395+
expect(th2.hasClass("renderable")).toBe(true);
396+
expect(th2.hasClass("year")).toBe(true);
397+
expect(th2.find("a").text()).toBe("year");
398+
expect(th2.find("a > b:last-child").eq(0).hasClass("sort-caret")).toBe(true);
360399
});
361400

362401
});

0 commit comments

Comments
 (0)