Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5aa71ba
Add function get-angle-type for future jest tests
Della-Bella Nov 15, 2024
7066639
Add function Angle type for future tests
Della-Bella Nov 15, 2024
3c6a10b
Implement Right angle/ Acute angle Tests
Della-Bella Nov 17, 2024
9620e5f
Adding Acute angle and Acute angle Tests
Della-Bella Nov 17, 2024
e2de22f
Tests GetAngleType donne
Della-Bella Nov 18, 2024
698ab29
Proper Fraction Tests
Della-Bella Nov 18, 2024
14e373b
Exercise Triangle Check Sides
Della-Bella Nov 21, 2024
4350e21
Exercise Triangle Sides
Della-Bella Nov 21, 2024
f369767
Implement and Test Rotate.jair exercise
Della-Bella Nov 22, 2024
632a715
implement and test Rotate.char Exercise
Della-Bella Nov 22, 2024
6b02231
Resolved Loop Exercise
Della-Bella Nov 22, 2024
761a92c
fixed link test name
Della-Bella Nov 22, 2024
b5488f5
fixed link test name
Della-Bella Nov 22, 2024
0bb8b5d
Implementing Function Repeat
Della-Bella Nov 22, 2024
7824b00
Implementing and testing password Validate function
Della-Bella Nov 22, 2024
f51874d
Implementing and testing password Validate function
Della-Bella Nov 22, 2024
1066bd1
Correct test Get ordinal number
Della-Bella Nov 22, 2024
c5c3e89
Adding test to Prime number function
Della-Bella Nov 22, 2024
2fa282a
Exercise Value Card- function ParseInt
Della-Bella Nov 24, 2024
9dfc6d8
Implement ParseInt function ? Get Value Card
Della-Bella Nov 24, 2024
801338c
Get Card Value function % test
Della-Bella Nov 24, 2024
f143753
Remove the Spaces
Della-Bella Dec 21, 2024
305c718
Removed unnecessary const code.
Della-Bella Dec 29, 2024
6aecd98
Test Values only for Valid Cards
Della-Bella Dec 29, 2024
6ce5774
Add new Test/ pPassed
Della-Bella Dec 29, 2024
9040843
Fixed/ Pass Tests
Della-Bella Dec 29, 2024
b84ac3b
Fixed Function and TAdd More Tests
Della-Bella Dec 29, 2024
17cdb66
Fixed Function and TAdd More Tests
Della-Bella Dec 29, 2024
f0a9c9a
Fixed Tests
Della-Bella Dec 29, 2024
4af63aa
Fixed Function= Added a condition to check if the last two digits are…
Della-Bella Dec 29, 2024
d127cd7
Fixed Password function & and Tests
Della-Bella Dec 29, 2024
bb1d1c2
Add Tests to Function Repeat
Della-Bella Dec 29, 2024
7b55dcb
Card Validator Function
Della-Bella Jan 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed Password function & and Tests
  • Loading branch information
Della-Bella committed Dec 29, 2024
commit d127cd70c54944648eea5fadb982af3647c0b596
44 changes: 39 additions & 5 deletions Sprint-3/revise/implement/password-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You must breakdown this problem in order to solve it. Find one test case
first and get that working
*/

function isNumberValid(input) {
/*function isNumberValid(input) {
if (typeof input === "number" && input >= 10000) {
return true; // Have at least 5 characters.
}
Expand All @@ -37,17 +37,51 @@ function isNumberValid(input) {
}
}
return false; // If none of the above checks passed, the input is not valid
}
}*/

// Examples of how the function works:
/* Examples of how the function works:
console.log(isNumberValid(15000)); // true (number >= 10000)
console.log(isNumberValid("A")); // true (single uppercase letter)
console.log(isNumberValid("z")); // true (single lowercase letter)
console.log(isNumberValid("5")); // true (single digit)
console.log(isNumberValid("*")); // true (special character)
console.log(isNumberValid("Hello")); // false (not valid)
console.log(isNumberValid(5000)); // false (number < 10000)
console.log(isNumberValid("!!")); // false (more than one character)
console.log(isNumberValid("!!")); // false (more than one character)*/

function isValidPassword(password, previousPasswords) {
// 1. Check password length
if (password.length < 5) {
return false;
}

// 2. Check for uppercase letter
if (!/[A-Z]/.test(password)) {
return false;
}

// 3. Check for lowercase letter
if (!/[a-z]/.test(password)) {
return false;
}

// 4. Check for number
if (!/\d/.test(password)) {
return false;
}

// 5. Check for special character
if (!/[!#$%&*.]/.test(password)) {
return false;
}

// 6. Check for previous passwords
if (previousPasswords.includes(password)) {
return false;
}

// All conditions met
return true;

module.exports = isNumberValid;
};
module.exports = isValidPassword;
53 changes: 50 additions & 3 deletions Sprint-3/revise/implement/password-validator.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

const isNumberValid = require("./password-validator");

test("Should validate a number with at least 5 characters", () => {

/*test("Should validate a number with at least 5 characters", () => {
const input = 112206;
const output = isNumberValid(input);
expect(output).toBe(true); // A valid number
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be invalid as the password does not pass all of the criteria.

These are the criteria as password that a valid password need to pass

Have at least 5 characters.

  • Have at least one English uppercase letter (A-Z)
  • Have at least one English lowercase letter (a-z)
  • Have at least one number (0-9)
  • Have at least one non-alphanumeric symbol ("!", "#", "$", "%", ".", "*", "&")
  • Must not be any previous password in the passwords array.

Expand All @@ -23,8 +23,55 @@ test("Should invalidate a special character not in the list", () => {
const input = "@";
const output = isNumberValid(input);
expect(output).toBe(false); // Invalid because "@" is not in the list of special characters
});
});*/


// passwordValidator.test.js
const isValidPassword = require('./password-validator');

describe('isValidPassword', () => {
it('should return true for a valid password', () => {
const password = 'MyStrongPass123!';
const previousPasswords = ["oldPass1", "oldPass2"];
expect(isValidPassword(password, previousPasswords)).toBe(true);
});

it('should return false for a password shorter than 5 characters', () => {
const password = 'Pass';
const previousPasswords = [];
expect(isValidPassword(password, previousPasswords)).toBe(false);
});

it('should return false if no uppercase letter is present', () => {
const password = 'mystrongpass123!';
const previousPasswords = [];
expect(isValidPassword(password, previousPasswords)).toBe(false);
});

it('should return false if no lowercase letter is present', () => {
const password = 'MYSTRONGPASS123!';
const previousPasswords = [];
expect(isValidPassword(password, previousPasswords)).toBe(false);
});

it('should return false if no digit is present', () => {
const password = 'MyStrongPass!';
const previousPasswords = [];
expect(isValidPassword(password, previousPasswords)).toBe(false);
});

it('should return false if no special character is present', () => {
const password = 'MyStrongPass123';
const previousPasswords = [];
expect(isValidPassword(password, previousPasswords)).toBe(false);
});

it('should return false if the password is in the previousPasswords array', () => {
const password = "oldPass1";
const previousPasswords = ["oldPass1", "oldPass2"];
expect(isValidPassword(password, previousPasswords)).toBe(false);
});
});



Expand Down