Skip to content

Commit

Permalink
Add test for presence of "Show/Hide All" button on intialise
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtrussler committed Jun 4, 2024
1 parent 3c35383 commit 627477d
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions spec/javascripts/spec/components/mainstream_table.spec.js
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.querySelector('th.govuk-table__header--controls')

expect(headerControls.querySelector('button')).not.toBeNull()
expect(headerControls.querySelector('button').classList).toContain('govuk-accordion__show-all')
expect(headerControls.querySelector('button').textContent).toBe('Show all')
})
})
})

0 comments on commit 627477d

Please sign in to comment.