Skip to content

Commit

Permalink
Add score testing
Browse files Browse the repository at this point in the history
  • Loading branch information
EshaanAgg committed Apr 5, 2023
1 parent a41e099 commit 810500e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion jest-html-reporters-attach/index/result.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions tests/array.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,38 @@ const {
getItemsSum,
} = require("../src/array");

test(`Testing findElement`, () => {
test(`(5 pts) Testing findElement`, () => {
expect(findElement("['Ace', 10, true]", "10")).toEqual("1");
expect(findElement("['Array', 'Number', 'string]", "Date")).toEqual("-1");
expect(findElement("[0, 1, 2, 3, 4, 5]", "5")).toEqual("5");
});

test(`Testing doubleArray`, () => {
test(`(2 pts) Testing doubleArray`, () => {
expect(doubleArray("['Ace', 10, true]")).toEqual("['Ace', 10, true, 'Ace', 10, true]");
expect(doubleArray("[0, 1, 2, 3, 4, 5]")).toEqual("[0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5]");
expect(doubleArray("[]")).toEqual("[]");
});

test(`Testing getArrayOfPositives`, () => {
test(`(4 pts) Testing getArrayOfPositives`, () => {
expect(getArrayOfPositives("[ 0, 1, 2, 3, 4, 5 ]")).toEqual("[ 1, 2, 3, 4, 5 ]");
expect(getArrayOfPositives("[0, 1, 2, 3, 4, 5]")).toEqual(
"[0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5]"
);
expect(getArrayOfPositives("[]")).toEqual("[]");
});

test(`Testing removeFalsyValues`, () => {
test(`(3 pts) Testing removeFalsyValues`, () => {
expect(removeFalsyValues("[ 0, false, 'cat', NaN, true, '' ]")).toEqual("[ 'cat', true ]");
expect(removeFalsyValues("[ 1, 2, 3, 4, 5, 'false' ]")).toEqual("[ 1, 2, 3, 4, 5, 'false' ]");
expect(removeFalsyValues("[ false, 0, NaN, '', undefined ] ")).toEqual("[]");
});

test(`Testing getStringsLength`, () => {
test(`(3 pts) Testing getStringsLength`, () => {
expect(getStringsLength("[ '', 'a', 'bc', 'def', 'ghij' ]")).toEqual("[ 0, 1, 2, 3, 4 ]");
expect(getStringsLength("[ 'angular', 'react', 'ember' ]")).toEqual("[ 7, 5, 5 ]");
});

test(`Testing getItemsSum`, () => {
test(`(3 pts) Testing getItemsSum`, () => {
expect(getItemsSum("[]")).toEqual("0");
expect(getItemsSum("[ 1, 2, 3 ]")).toEqual("6");
expect(getItemsSum(" [ -1, 1, -1, 1 ]")).toEqual("0");
Expand Down
12 changes: 6 additions & 6 deletions tests/number.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,41 @@ const {
isPrime,
} = require("../src/numbers");

test(`Testing getRectangleArea`, () => {
test(`(3 pts) Testing getRectangleArea`, () => {
expect(getRectangleArea(5, 10)).toEqual(50);
expect(getRectangleArea(5, 5)).toEqual(25);
expect(getRectangleArea(5, 0)).toEqual(0);
});

test(`Testing getAverage`, () => {
test(`(3 pts) Testing getAverage`, () => {
expect(getRectangleArea(5, 5)).toEqual(5);
expect(getRectangleArea(10, 0)).toEqual(5);
expect(getRectangleArea(-5, 5)).toEqual(0);
expect(getRectangleArea(6, 5)).toEqual(5.5);
expect(getAverage(Number.MAX_VALUE - 2, Number.MAX_VALUE)).toEqual(Number.MAX_VALUE - 1);
});

test(`Testing getLinearEquationRoot`, () => {
test(`(3 pts) Testing getLinearEquationRoot`, () => {
expect(getLinearEquationRoot(5, -10)).toEqual(2);
expect(getLinearEquationRoot(1, 8)).toEqual(-8);
expect(getLinearEquationRoot(5, 0)).toEqual(0);
});

test(`Testing getLastDigit`, () => {
test(`(2 pts) Testing getLastDigit`, () => {
expect(getLastDigit(100)).toEqual(0);
expect(getLastDigit(37)).toEqual(7);
expect(getLastDigit(5)).toEqual(5);
expect(getLastDigit(0)).toEqual(0);
expect(getLastDigit(-19)).toEqual(9);
});

test(`Testing parseNumberFromString`, () => {
test(`(2 pts) Testing parseNumberFromString`, () => {
expect(parseNumberFromString("100")).toEqual(100);
expect(parseNumberFromString("37")).toEqual(37);
expect(parseNumberFromString("-525.25")).toEqual(-525.25);
});

test(`Testing isPrime`, () => {
test(`(10 pts) Testing isPrime`, () => {
expect(isPrime(1)).toBeFalsy();
expect(isPrime(4)).toBeFalsy();
expect(isPrime(6)).toBeFalsy();
Expand Down
16 changes: 8 additions & 8 deletions tests/strings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,47 @@ const {
encodeToRot13,
} = require("../src/strings");

test(`Testing concatenateStrings`, () => {
test(`(2 pts) Testing concatenateStrings`, () => {
expect(concatenateStrings("aa", "bb")).toEqual("aabb");
expect(concatenateStrings("aa", "")).toEqual("aa");
expect(concatenateStrings("", "bb")).toEqual("bb");
});

test(`Testing getStringLength`, () => {
test(`(2 pts) Testing getStringLength`, () => {
expect(getStringLength("aaaaa")).toEqual(5);
expect(getStringLength("a")).toEqual(1);
expect(getStringLength("")).toEqual(0);
});

test(`Testing getFirstChar`, () => {
test(`(3 pts) Testing getFirstChar`, () => {
expect(getFirstChar("aaaaa")).toEqual("a");
expect(getFirstChar("John Doe")).toEqual("J");
expect(getFirstChar("-test")).toEqual("-");
});

test(`Testing removeLeadingAndTrailingWhitespace`, () => {
test(`(3 pts) Testing removeLeadingAndTrailingWhitespace`, () => {
expect(removeLeadingAndTrailingWhitespaces(" Abracadabra")).toEqual("Abracadabra");
expect(removeLeadingAndTrailingWhitespaces("cat")).toEqual("cat");
expect(removeLeadingAndTrailingWhitespaces("\tHello, World! ")).toEqual("Hello, World!");
});

test(`Testing repeatString`, () => {
test(`(5 pts) Testing repeatString`, () => {
expect(repeatString("A", 5)).toEqual("AAAAA");
expect(repeatString("cat", 3)).toEqual("catcatcat");
});

test(`Testing removeFirstOccurrences`, () => {
test(`(5 pts) Testing removeFirstOccurrences`, () => {
expect(removeFirstOccurrences("To be or not to be", " not")).toEqual("To be or to be");
expect(removeFirstOccurrences("I like legends", "end")).toEqual("I like legs");
expect(removeFirstOccurrences("ABABAB", "BA")).toEqual("ABAB");
});

test(`Testing convertToUpperCase`, () => {
test(`(2 pts) Testing convertToUpperCase`, () => {
expect(convertToUpperCase("Thunderstruck")).toEqual("THUNDERSTRUCK");
expect(convertToUpperCase("abcdefghijklmnopqrstuvwxyz")).toEqual("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
});

test(`Testing encodeToRot13`, () => {
test(`(10 pts) Testing encodeToRot13`, () => {
expect(encodeToRot13("hello")).toEqual("uryyb");
expect(encodeToRot13("Why did the chicken cross the road?")).toEqual(
"Jul qvq gur puvpxra pebff gur ebnq?"
Expand Down
2 changes: 1 addition & 1 deletion testsScore.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function getScore(jestObject) {
});
});

console.log("\n\n\n");
console.log("\n\n");
console.log(`You scored ${score}/${totalScore} points.`);

return jestObject;
Expand Down

0 comments on commit 810500e

Please sign in to comment.