Skip to content

Commit

Permalink
fix: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerlinsley committed Aug 3, 2020
1 parent fdb1ebe commit ec8dcb1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
9 changes: 4 additions & 5 deletions src/plugin-hooks/tests/useRowSelect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,13 @@ function Table({ columns, data }) {
headerGroups,
rows,
prepareRow,
state: { selectedRowIds },
} = useTable(
{
columns,
data,
},
useRowSelect,
useExpanded,
useRowSelect,
hooks => {
hooks.visibleColumns.push(columns => [
// Let's make a column for selection
Expand Down Expand Up @@ -218,15 +217,15 @@ test('renders a table with selectable rows', () => {

fireEvent.click(rtl.getByLabelText('Select All'))

expect(rtl.getAllByText('Selected').length).toBe(24)
expect(rtl.getAllByText('Selected').length).toBe(36)

fireEvent.click(rtl.getAllByLabelText('Select Row')[2])

expect(rtl.queryAllByText('Selected').length).toBe(23)
expect(rtl.queryAllByText('Selected').length).toBe(33)

fireEvent.click(rtl.getByLabelText('Select All'))

expect(rtl.queryAllByText('Selected').length).toBe(24)
expect(rtl.queryAllByText('Selected').length).toBe(36)

fireEvent.click(rtl.getByLabelText('Select All'))

Expand Down
14 changes: 12 additions & 2 deletions src/plugin-hooks/tests/useSortBy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,12 @@ test('Test initialState.sortBy: When clicking the last sortBy column, the sorted
.queryAllByRole('row')
.slice(2)
.map(d => d.children[0].textContent)
).toEqual(['firstName: tanner', 'firstName: derek', 'firstName: joe'])
).toEqual([
'firstName: tanner',
'firstName: derek',
'firstName: joe',
'firstName: john',
])

fireEvent.click(rendered.getByText('Age 🔼0'))
rendered.getByText('Age 🔽0')
Expand All @@ -259,7 +264,12 @@ test('Test initialState.sortBy: When clicking the last sortBy column, the sorted
.queryAllByRole('row')
.slice(2)
.map(d => d.children[0].textContent)
).toEqual(['firstName: joe', 'firstName: derek', 'firstName: tanner'])
).toEqual([
'firstName: john',
'firstName: joe',
'firstName: derek',
'firstName: tanner',
])

fireEvent.click(rendered.getByText('Age 🔽0'))
rendered.getByText('Age')
Expand Down
7 changes: 5 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react'
import { defaultColumn, emptyRenderer } from './publicUtils'

// Find the depth of the columns
Expand Down Expand Up @@ -86,7 +85,11 @@ export function decorateColumn(column, userDefaultColumn) {
}

// Build the header groups from the bottom up
export function makeHeaderGroups(allColumns, defaultColumn, additionalHeaderProperties = () => ({})) {
export function makeHeaderGroups(
allColumns,
defaultColumn,
additionalHeaderProperties = () => ({})
) {
const headerGroups = []

let scanColumns = allColumns
Expand Down

1 comment on commit ec8dcb1

@vercel
Copy link

@vercel vercel bot commented on ec8dcb1 Aug 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.