Skip to content

Commit

Permalink
PassChecker Iteration 1
Browse files Browse the repository at this point in the history
  • Loading branch information
barosanuemailtest committed Feb 3, 2023
1 parent 635fddc commit f8618d6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
13 changes: 11 additions & 2 deletions src/app/pass_checker/PasswordChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@

export class PasswordChecker {

public checkPassword(){

public checkPassword(password: string): boolean{
if(password.length < 8) {
return false;
}
if (password == password.toLowerCase()) {
return false;
}
if (password == password.toUpperCase()) {
return false;
}
return true;
}
}
36 changes: 31 additions & 5 deletions src/test/pass_checker/PasswordChecker.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,43 @@
import { PasswordChecker } from "../../app/pass_checker/PasswordChecker"


describe('PasswordChecker test suite', ()=>{
describe('PasswordChecker test suite', () => {

let sut: PasswordChecker;

beforeEach(()=>{
beforeEach(() => {
sut = new PasswordChecker();
})

it('Should do nothing for the moment', ()=>{
sut.checkPassword();
})
it('Password with less than 8 chars is invalid', () => {
const actual = sut.checkPassword('1234567');
expect(actual).toBe(false);
});

it('Password with more than 8 chars is ok', () => {
const actual = sut.checkPassword('12345678Aa');
expect(actual).toBe(true);
});

it('Password with no upper case letter is invalid', () => {
const actual = sut.checkPassword('1234abcd');
expect(actual).toBe(false);
});

it('Password with upper case letter is valid', () => {
const actual = sut.checkPassword('1234abcdA');
expect(actual).toBe(true);
});

it('Password with no lower case letter is invalid', () => {
const actual = sut.checkPassword('1234ABCD');
expect(actual).toBe(false);
});

it('Password with lower case letter is valid', () => {
const actual = sut.checkPassword('1234ABCDa');
expect(actual).toBe(true);
});


})

0 comments on commit f8618d6

Please sign in to comment.