Skip to content

Commit

Permalink
test(ui-table): migrate old Table tests
Browse files Browse the repository at this point in the history
Closes: INSTUI-4133
  • Loading branch information
ToMESSKa committed Jul 26, 2024
1 parent c58fff8 commit 537ef8d
Show file tree
Hide file tree
Showing 5 changed files with 630 additions and 101 deletions.
60 changes: 60 additions & 0 deletions cypress/component/Table.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 - present Instructure, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

import React from 'react'
import '../support/component'
import 'cypress-real-events'

import { Table } from '../../packages/ui'

describe('<Table/>', () =>
it('can render table head as a combobox when in stacked layout', async () => {
const sortFoo = cy.stub()
cy.mount(
<Table caption="Sortable table" layout="stacked">
<Table.Head>
<Table.Row>
<Table.ColHeader id="id" onRequestSort={sortFoo}>
Foo
</Table.ColHeader>
<Table.ColHeader id="bar" onRequestSort={sortFoo}>
Bar
</Table.ColHeader>
</Table.Row>
</Table.Head>
<Table.Body>
<Table.Row></Table.Row>
<Table.Row></Table.Row>
</Table.Body>
</Table>
)

const input = cy.get('input[role="combobox"]')

input.click()

cy.get('[role="option"]').first().click()

cy.wrap(sortFoo).should('have.been.calledOnce')
}))
Loading

0 comments on commit 537ef8d

Please sign in to comment.