Skip to content

Commit

Permalink
Add Password Tests (#370)
Browse files Browse the repository at this point in the history
* WIP: Password test

* Add Password Test
  • Loading branch information
pivilartisant authored Nov 8, 2023
1 parent 200e47a commit 4b92687
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 60 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
118 changes: 118 additions & 0 deletions cypress/component/integration/Password.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import '../../../src/global.css';
import { Password } from '../../../src/components';
import { compareSnapshot } from '../../compareSnapshot';

describe('Component | Integration | Password', function () {
describe('Input', () => {
describe('default password', () => {
beforeEach(() => {
cy.mount(
<div className="theme-dark">
<Password />
</div>,
);
});

it('should render', () => {
cy.get('[data-testid="password-input"]').should('exist');
});

it('should focus on click', () => {
cy.get('[data-testid="password-input"]').focus().should('be.focused');
});

it('should receive typed input', () => {
cy.get('[data-testid="password-input"]')
.type('typed content')
.should('have.value', 'typed content')
.clear();
});

it('should hide typed input', () => {
cy.get('[data-testid="password-input"]')
.type('typed content')
.should('have.value', 'typed content');
cy.get('[data-testid="password-input"]').should('have.attr', 'type');
cy.get('[data-testid="password-input"]')
.invoke('attr', 'type')
.should('eq', 'password');
});

it('should show typed input', () => {
cy.get('[data-testid="password-input"]')
.type('typed content')
.should('have.value', 'typed content');

cy.get('[data-testid="password-icon"]').should('exist').click();

cy.get('[data-testid="password-input"]')
.invoke('attr', 'type')
.should('eq', 'text');
});

it('should show typed input', () => {
cy.get('[data-testid="password-input"]')
.type('typed content')
.should('have.value', 'typed content');

cy.get('[data-testid="password-icon"]').should('exist').click();

cy.get('[data-testid="password-input"]')
.invoke('attr', 'type')
.should('eq', 'text');
});

it('should match snapshot', () => {
compareSnapshot(cy, 'default-password');
});
});

describe('default password with error', () => {
beforeEach(() => {
cy.mount(
<div className="theme-dark">
<Password error={'error'} />
</div>,
);
});

it('should render', () => {
cy.get('[data-testid="password-input"]').should('exist');
});

it('should display error message', () => {
cy.get('[data-testid="input-field-message"]')
.should('exist')
.contains('error');
});

it('should match snapshot', () => {
compareSnapshot(cy, 'default-password-with-error');
});
});

describe('default password with warning', () => {
beforeEach(() => {
cy.mount(
<div className="theme-dark">
<Password warning={'warning'} />
</div>,
);
});

it('should render', () => {
cy.get('[data-testid="password-input"]').should('exist');
});

it('should display warning message', () => {
cy.get('[data-testid="input-field-message"]')
.should('exist')
.contains('warning');
});

it('should match snapshot', () => {
compareSnapshot(cy, 'default-password-with-warning');
});
});
});
});
60 changes: 0 additions & 60 deletions src/components/Password/Password.test.tsx

This file was deleted.

0 comments on commit 4b92687

Please sign in to comment.