Skip to content

Commit

Permalink
test(kdropdown): add kdropdownitem tests
Browse files Browse the repository at this point in the history
  • Loading branch information
portikM committed Nov 1, 2023
1 parent a25da08 commit 7aaec14
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions src/components/KDropdown/KDropdown.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,38 @@ describe('KDropdown', () => {
cy.getTestId('dropdown-list').eq(0).find('.k-dropdown-item').should('have.length', 6)
cy.getTestId('dropdown-list').eq(0).find('.has-divider').should('have.length', 2)

cy.get('button[data-testid="button"]').should('be.visible')
cy.get('button[data-testid="disabled-button"]').should('be.visible').should('be.disabled')
cy.get('[data-testid="button"] button').should('be.visible')
cy.get('[data-testid="disabled-button"] button').should('be.visible').should('be.disabled')

cy.get('router-link[data-testid="router-link"]').should('be.visible')
cy.get('router-link[data-testid="disabled-router-link"]').should('be.visible').should('have.attr', 'disabled')
cy.get('[data-testid="router-link"] router-link').should('be.visible')
cy.get('[data-testid="disabled-router-link"] router-link').should('be.visible').should('have.attr', 'disabled')

cy.get('a[data-testid="external-link"]').should('be.visible')
cy.get('a[data-testid="disabled-external-link"]').should('be.visible').should('have.attr', 'disabled')
cy.get('[data-testid="external-link"] a').should('be.visible')
cy.get('[data-testid="disabled-external-link"] a').should('be.visible').should('have.attr', 'disabled')
})
})

describe('KDropdownItem', () => {
// TODO: add more KDropdownItem tests

it('correctly binds attributes to wrapper and trigger elements', () => {
const testIdAttr = 'dropdown-item-test'

mount(KDropdownItem, {
props: {
item: {
label: 'You are here',
to: { path: '/' },
},
},
attrs: {
target: '_blank',
'data-testid': testIdAttr,
},
})

cy.getTestId('dropdown-item').should('not.exist')
cy.getTestId(testIdAttr).should('be.visible')
cy.getTestId(testIdAttr).find('[data-testid="dropdown-item-trigger"]').should('have.attr', 'target', '_blank')
})
})

0 comments on commit 7aaec14

Please sign in to comment.