This repository contains unit tests for the LoginComponent
in an Angular application. It ensures the login form behaves correctly, with validation rules and maximum length constraints.
Desktop.2025.03.28.-.18.37.25.04.mp4
- Angular (version 19)
- Jasmine & Karma (for testing)
- SweetAlert2 (for modal handling)
- Should create the
LoginComponent
.
- Should create a form with
username
andpassword
fields. - Should make the
username
andpassword
fields required. - Should mark the form as invalid when fields are empty.
- Should mark the form as valid when required fields are filled.
- Should make the
username
invalid if it exceeds max length. - Should make the
password
invalid if it exceeds max length. - Should make the
username
valid if it's within max length. - Should make the
password
valid if it's within max length.
- Should return true when login is successful.
- Should return false when login fails with incorrect credentials.
- Should dismiss SweetAlert modal after each test by simulating
Esc
key or callingSwal.close()
.
git clone https://github.com/your-username/angular-login-testing.git
cd angular-login-testing
npm install
ng s
ng test