Skip to content

Commit f4873d1

Browse files
Resolve merge conflicts - keep implementation
2 parents f89c2e1 + 3372770 commit f4873d1

File tree

16 files changed

+200
-268
lines changed

16 files changed

+200
-268
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/pd-assignment.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/tech-ed-assignment.yml

Lines changed: 0 additions & 88 deletions
This file was deleted.

.github/pull_request_template.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

Sprint-3/1-implement-and-rewrite-tests/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Implement solutions and rewrite tests with Jest
22

3+
Before writing any code, please read the [Testing Function Guide](testing-guide.md) to learn how
4+
to choose test values that thoroughly test a function.
5+
36
## 1 Implement solutions
47

58
In the `implement` directory you've got a number of functions you'll need to implement.

Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
// Implement a function getAngleType
2-
// Build up your function case by case, writing tests as you go
3-
// The first test and case is written for you. The next case has a test, but no code.
4-
// Execute this script in your terminal
5-
// node 1-get-angle-type.js
6-
// The assertion error will tell you what the expected output is
7-
// Write the code to pass the test
8-
// Then, write the next test! :) Go through this process until all the cases are implemented
2+
//
3+
// When given an angle in degrees, it should return a string indicating the type of angle:
4+
// - "Acute angle" for angles greater than 0° and less than 90°
5+
// - "Right angle" for exactly 90°
6+
// - "Obtuse angle" for angles greater than 90° and less than 180°
7+
// - "Straight angle" for exactly 180°
8+
// - "Reflex angle" for angles greater than 180° and less than 360°
9+
// - "Invalid angle" for angles outside the valid range.
10+
11+
// Assumption: The parameter is a valid number. (You do not need to handle non-numeric inputs.)
12+
13+
// Acceptance criteria:
14+
// After you have implemented the function, write tests to cover all the cases, and
15+
// execute the code to ensure all tests pass.
916

1017
function getAngleType(angle) {
1118
if (angle === 90) {
@@ -27,24 +34,17 @@ function getAngleType(angle) {
2734
// This will be useful in the "rewrite tests with jest" step.
2835
module.exports = getAngleType;
2936

30-
// we're going to use this helper function to make our assertions easier to read
31-
// if the actual output matches the target output, the test will pass
37+
// This helper function is written to make our assertions easier to read.
38+
// If the actual output matches the target output, the test will pass
3239
function assertEquals(actualOutput, targetOutput) {
3340
console.assert(
3441
actualOutput === targetOutput,
3542
`Expected ${actualOutput} to equal ${targetOutput}`
3643
);
3744
}
3845

39-
// Acceptance criteria:
40-
41-
// Given an angle in degrees,
42-
// When the function getAngleType is called with this angle,
43-
// Then it should:
44-
45-
// Case 1: Identify Right Angles:
46-
// When the angle is exactly 90 degrees,
47-
// Then the function should return "Right angle"
46+
// TODO: Write tests to cover all cases, including boundary and invalid cases.
47+
// Example: Identify Right Angles
4848
const right = getAngleType(90);
4949
assertEquals(right, "Right angle");
5050

Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
// Implement a function isProperFraction
2-
// Write assertions for your function to check it works in different cases
3-
// Terms:
4-
// Fractions: https://www.bbc.co.uk/bitesize/topics/zt9n6g8/articles/zjxpp4j
5-
// Written here like this: 1/2 == Numerator/Denominator
6-
// the first test and first case is written for you
7-
// complete the rest of the tests and cases
8-
// write one test at a time, and make it pass, build your solution up methodically
1+
// Implement a function isProperFraction,
2+
// when given two numbers, a numerator and a denominator, it should return true if
3+
// the given numbers form a proper fraction, and false otherwise.
4+
5+
// Assumption: The parameters are valid numbers (not NaN or Infinity).
6+
7+
// Note: If you are unfamiliar with proper fractions, please look up its mathematical definition.
8+
9+
// Acceptance criteria:
10+
// After you have implemented the function, write tests to cover all the cases, and
11+
// execute the code to ensure all tests pass.
912

1013
function isProperFraction(numerator, denominator) {
1114
if (!numerator || !denominator) return "Incomplete fraction";
@@ -19,15 +22,16 @@ function isProperFraction(numerator, denominator) {
1922
// This will be useful in the "rewrite tests with jest" step.
2023
module.exports = isProperFraction;
2124

22-
// here's our helper again
25+
// Here's our helper again
2326
function assertEquals(actualOutput, targetOutput) {
2427
console.assert(
2528
actualOutput === targetOutput,
2629
`Expected ${actualOutput} to equal ${targetOutput}`
2730
);
2831
}
2932

30-
// Acceptance criteria:
33+
// TODO: Write tests to cover all cases.
34+
// What combinations of numerators and denominators should you test?
3135

3236
// Proper Fraction check:
3337
// Input: numerator = 2, denominator = 3

Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
// This problem involves playing cards: https://en.wikipedia.org/wiki/Standard_52-card_deck
22

3-
// You will need to implement a function getCardValue
4-
// the function takes a single parameter, a string representing a playing card
5-
// the function should return the numerical value of the card
6-
// the first test and first case is written for you
7-
// complete the rest of the tests and cases
8-
// write one test at a time, and make it pass, build your solution up methodically
9-
// just make one change at a time -- don't rush -- programmers are deep and careful thinkers
3+
// Implement a function getCardValue, when given a string representing a playing card,
4+
// should return the numerical value of the card.
5+
6+
// A valid card string will contain a rank followed by the suit.
7+
// The rank can be one of the following strings:
8+
// "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"
9+
// The suit can be one of the following emojis:
10+
// "♠", "♥", "♦", "♣"
11+
// For example: "A♠", "2♥", "10♥", "J♣", "Q♦", "K♦".
12+
13+
// When the card is an ace ("A"), the function should return 11.
14+
// When the card is a face card ("J", "Q", "K"), the function should return 10.
15+
// When the card is a number card ("2" to "10"), the function should return its numeric value.
16+
17+
// When the card string is invalid (not following the above format), the function should
18+
// throw an error.
19+
20+
// Acceptance criteria:
21+
// After you have implemented the function, write tests to cover all the cases, and
22+
// execute the code to ensure all tests pass.
23+
1024
function getCardValue(card) {
1125
let rank = card.slice(0, -1);
1226
let cardFace = card[card.length - 1];
@@ -32,9 +46,7 @@ function getCardValue(card) {
3246
// This will be useful in the "rewrite tests with jest" step.
3347
module.exports = getCardValue;
3448

35-
// You need to write assertions for your function to check it works in different cases
36-
// we're going to use this helper function to make our assertions easier to read
37-
// if the actual output matches the target output, the test will pass
49+
// Helper functions to make our assertions easier to read.
3850
function assertEquals(actualOutput, targetOutput) {
3951
console.assert(
4052
actualOutput === targetOutput,

Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22
// We will use the same function, but write tests for it using Jest in this file.
33
const getAngleType = require("../implement/1-get-angle-type");
44

5-
test("should identify right angle (90°)", () => {
6-
expect(getAngleType(90)).toEqual("Right angle");
5+
// TODO: Write tests in Jest syntax to cover all cases/outcomes,
6+
// including boundary and invalid cases.
7+
8+
// Case 1: Acute angles
9+
test(`should return "Acute angle" when (0 < angle < 90)`, () => {
10+
// Test various acute angles, including boundary cases
11+
expect(getAngleType(1)).toEqual("Acute angle");
12+
expect(getAngleType(45)).toEqual("Acute angle");
13+
expect(getAngleType(89)).toEqual("Acute angle");
714
});
815

916
// REPLACE the comments with the tests
@@ -37,4 +44,4 @@ test("should identify straight angle(180°)",()=>{
3744
// Then the function should return "Reflex angle"
3845
test("should identify reflex angle(280°)",()=>{
3946
expect(getAngleType(280)).toEqual("Reflex angle")
40-
});
47+
});

0 commit comments

Comments
 (0)