Skip to content

Commit

Permalink
test(ktableview): update component tests [KHCP-14243]
Browse files Browse the repository at this point in the history
  • Loading branch information
portikM committed Nov 26, 2024
1 parent 890e2ca commit a4732d7
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions src/components/KTableView/KTableView.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const options = {
id: '517526354743085',
enabled: 'true',
expandable: true,
expanded: true,
},
{
name: 'Website Desktop',
Expand Down Expand Up @@ -560,17 +561,43 @@ describe('KTableView', () => {
})
})

it('emits row-expand event when row is expanded', () => {
it('renders a row expanded when rowExpanded prop returns true', () => {
cy.mount(KTableView, {
props: {
headers: options.headers,
data: options.data,
rowExpandable: () => true,
rowExpanded: (row: any) => row.expanded,
},
slots: {
'row-expanded': '<span data-testid="slotted-expandable-content">Expandable content</span>',
},
})

cy.getTestId('expandable-row-control').should('have.length', options.data.length).should('be.visible')
cy.getTestId('expandable-content-row').should('have.length', options.data.length)

cy.getTestId('expandable-content-row').findTestId('slotted-expandable-content').should('be.visible')
cy.getTestId('expandable-row-control').eq(0).click().then(() => {
cy.wrap(Cypress.vueWrapper.emitted()).should('have.property', 'row-expand').and('have.length', 1)
cy.getTestId('expandable-content-row').eq(0).findTestId('slotted-expandable-content').should('not.be.visible')
})
})

it('emits update:row-expanded event when row is expanded and collapsed', () => {
cy.mount(KTableView, {
props: {
headers: options.headers,
data: options.data,
rowExpandable: () => true,
},
})

cy.getTestId('expandable-row-control').eq(0).click().then(() => {
cy.wrap(Cypress.vueWrapper.emitted()).should('have.property', 'update:row-expanded').and('have.length', 1)

cy.getTestId('expandable-row-control').eq(0).click().then(() => {
cy.wrap(Cypress.vueWrapper.emitted()).should('have.property', 'update:row-expanded').and('have.length', 2)
})
})
})

Expand Down

0 comments on commit a4732d7

Please sign in to comment.