Skip to content

Commit

Permalink
test(kinput): add slot tests [KHCP-8985]
Browse files Browse the repository at this point in the history
  • Loading branch information
portikM committed Oct 11, 2023
1 parent da55db3 commit 9c6aa27
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/components/KInput/KInput.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ describe('KInput', () => {
cy.get('.k-input-label .kong-icon-infoFilled').should('exist').and('be.visible')
})

it.skip('renders label with required symbol when `required` attribute is set', () => { })
it.skip('renders label with required symbol when `required` attribute is set', () => {
// TODO: implement when KLabel component is reskinned
})

it('renders help when value is passed', () => {
const helpText = 'I am helpful'
Expand All @@ -108,7 +110,7 @@ describe('KInput', () => {

cy.get('.k-input-wrapper .over-char-limit').should('not.exist')
cy.get('.k-input-wrapper input.k-input').type(`This input has ${textCharCount} characters`)
cy.get('.k-input-wrapper.error .help-text').should('contain.text', `${textCharCount} / ${charLimit}`)
cy.get('.k-input-wrapper.has-error .help-text').should('contain.text', `${textCharCount} / ${charLimit}`)
})

it('reacts to text changes', () => {
Expand All @@ -130,7 +132,27 @@ describe('KInput', () => {
})
})

it.skip('renders before slot when passed', () => { })
it('renders before slot when passed', () => {
const beforeSlot = 'before-slot'

mount(KInput, {
slots: {
before: `<span data-testid="${beforeSlot}">Before slot</span>`,
},
})

cy.get('.k-input-wrapper').find(`[data-testid="${beforeSlot}"]`).should('be.visible')
})

it.skip('renders after slot when passed', () => { })
it('renders after slot when passed', () => {
const afterSlot = 'after-slot'

mount(KInput, {
slots: {
before: `<span data-testid="${afterSlot}">After slot</span>`,
},
})

cy.get('.k-input-wrapper').find(`[data-testid="${afterSlot}"]`).should('be.visible')
})
})

0 comments on commit 9c6aa27

Please sign in to comment.