-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for presence of "Show/Hide All" button on intialise
- Loading branch information
1 parent
344611c
commit 84e2b5e
Showing
1 changed file
with
22 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,38 @@ | ||
/* global GOVUK */ | ||
|
||
describe('Table component', function () { | ||
'use strict' | ||
|
||
var table, mainstreamTable | ||
|
||
beforeEach(function () { | ||
table = $('<table data-module="mainstream-table"></table>') | ||
var tableHtml = | ||
`<thead> | ||
<tr> | ||
<th>Title</th> | ||
<th>Assigned to</th> | ||
<th>Status</th> | ||
<th class="govuk-table__header--controls"></th> | ||
</tr> | ||
</thead>` | ||
|
||
$('body').append(table) | ||
table = document.createElement('table') | ||
table.innerHTML = tableHtml | ||
document.body.appendChild(table) | ||
|
||
mainstreamTable = new GOVUK.Modules.MainstreamTable() | ||
mainstreamTable = new GOVUK.Modules.MainstreamTable(table) | ||
mainstreamTable.init() | ||
}) | ||
|
||
afterEach(function () { | ||
table.remove() | ||
document.body.removeChild(table) | ||
}) | ||
|
||
describe('when first initialized', function () { | ||
it('should do nothing', function() { | ||
expect(1).toBe(1) | ||
describe('When initialised', function () { | ||
it('should have a "Show/Hide All" button', function () { | ||
var headerControls = table.querySelectorAll('th')[3] | ||
|
||
expect(headerControls.querySelector('button')).not.toBeNull() | ||
expect(headerControls.querySelector('button').classList).toContain('govuk-accordion__show-all') | ||
expect(headerControls.querySelector('button').textContent).toBe('Show all') | ||
}) | ||
}) | ||
}) |