-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #947 from takenet/feat/cypress-avatar
feat(avatar): add cypress test on Avatar
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { BdsAvatar } from '../dist/blip-ds-react'; | ||
|
||
describe('Teste de Renderização avatar', () => { | ||
// Teste de Renderização | ||
it('deve renderizar o avatar com o name correto', () => { | ||
cy.mount(<BdsAvatar name="Michael Scott" />); | ||
cy.get('bds-avatar').should('have.attr', 'name', 'Michael Scott'); | ||
}); | ||
it('deve renderizar o avatar com o thumbnail correto', () => { | ||
cy.mount(<BdsAvatar thumbnail="https://www.blip.ai/scripts-bot/icons/blipinho-widget.svg" />); | ||
cy.get('bds-avatar').should('have.attr', 'thumbnail', 'https://www.blip.ai/scripts-bot/icons/blipinho-widget.svg'); | ||
}); | ||
}); | ||
|
||
describe('Teste de Eventos avatar', () => { | ||
// Teste de Evento onBdsClickAvatar | ||
it('deve chamar o evento onBdsClickAvatar ao clicar no componente', () => { | ||
cy.mount(<BdsAvatar name="Michael Scott" upload onBdsClickAvatar={cy.stub().as('bdsClickAvatar')} />); | ||
cy.get('bds-avatar').click(); | ||
cy.get('@bdsClickAvatar').should('have.been.called'); | ||
}); | ||
}); | ||
|
||
describe('Teste de Acessibilidade avatar', () => { | ||
// Teste de Acessibilidade com Tab | ||
it('deve ser possível navegar para o avatar usando a tecla Tab', () => { | ||
cy.mount( | ||
<> | ||
<button>Botão anterior</button> | ||
<BdsAvatar name="Michael Scott" /> | ||
</>, | ||
); | ||
cy.get('button').first().focus(); | ||
cy.wait(50); | ||
cy.realPress('Tab'); | ||
cy.wait(50); | ||
cy.get('bds-avatar').should('have.focus'); | ||
}); | ||
}); |