Skip to content

Commit 3bf605b

Browse files
Merge branch 'CodeYourFuture:main' into coursework/sprint-3-dead-code
2 parents 33b2e4b + 3372770 commit 3bf605b

File tree

16 files changed

+235
-388
lines changed

16 files changed

+235
-388
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.
Lines changed: 19 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,37 @@
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) {
11-
if (angle === 90) {
12-
return "Right angle";
13-
}
14-
// Run the tests, work out what Case 2 is testing, and implement the required code here.
15-
// Then keep going for the other cases, one at a time.
18+
// TODO: Implement this function
1619
}
1720

1821
// The line below allows us to load the getAngleType function into tests in other files.
1922
// This will be useful in the "rewrite tests with jest" step.
2023
module.exports = getAngleType;
2124

22-
// we're going to use this helper function to make our assertions easier to read
23-
// if the actual output matches the target output, the test will pass
25+
// This helper function is written to make our assertions easier to read.
26+
// If the actual output matches the target output, the test will pass
2427
function assertEquals(actualOutput, targetOutput) {
2528
console.assert(
2629
actualOutput === targetOutput,
2730
`Expected ${actualOutput} to equal ${targetOutput}`
2831
);
2932
}
3033

31-
// Acceptance criteria:
32-
33-
// Given an angle in degrees,
34-
// When the function getAngleType is called with this angle,
35-
// Then it should:
36-
37-
// Case 1: Identify Right Angles:
38-
// When the angle is exactly 90 degrees,
39-
// Then the function should return "Right angle"
34+
// TODO: Write tests to cover all cases, including boundary and invalid cases.
35+
// Example: Identify Right Angles
4036
const right = getAngleType(90);
4137
assertEquals(right, "Right angle");
42-
43-
// Case 2: Identify Acute Angles:
44-
// When the angle is less than 90 degrees,
45-
// Then the function should return "Acute angle"
46-
const acute = getAngleType(45);
47-
assertEquals(acute, "Acute angle");
48-
49-
// Case 3: Identify Obtuse Angles:
50-
// When the angle is greater than 90 degrees and less than 180 degrees,
51-
// Then the function should return "Obtuse angle"
52-
const obtuse = getAngleType(120);
53-
// ====> write your test here, and then add a line to pass the test in the function above
54-
55-
// Case 4: Identify Straight Angles:
56-
// When the angle is exactly 180 degrees,
57-
// Then the function should return "Straight angle"
58-
// ====> write your test here, and then add a line to pass the test in the function above
59-
60-
// Case 5: Identify Reflex Angles:
61-
// When the angle is greater than 180 degrees and less than 360 degrees,
62-
// Then the function should return "Reflex angle"
63-
// ====> write your test here, and then add a line to pass the test in the function above
Lines changed: 17 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,33 @@
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) {
11-
if (numerator < denominator) {
12-
return true;
13-
}
14+
// TODO: Implement this function
1415
}
1516

1617
// The line below allows us to load the isProperFraction function into tests in other files.
1718
// This will be useful in the "rewrite tests with jest" step.
1819
module.exports = isProperFraction;
1920

20-
// here's our helper again
21+
// Here's our helper again
2122
function assertEquals(actualOutput, targetOutput) {
2223
console.assert(
2324
actualOutput === targetOutput,
2425
`Expected ${actualOutput} to equal ${targetOutput}`
2526
);
2627
}
2728

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

30-
// Proper Fraction check:
31-
// Input: numerator = 2, denominator = 3
32-
// target output: true
33-
// Explanation: The fraction 2/3 is a proper fraction, where the numerator is less than the denominator. The function should return true.
34-
const properFraction = isProperFraction(2, 3);
35-
assertEquals(properFraction, true);
36-
37-
// Improper Fraction check:
38-
// Input: numerator = 5, denominator = 2
39-
// target output: false
40-
// Explanation: The fraction 5/2 is an improper fraction, where the numerator is greater than or equal to the denominator. The function should return false.
41-
const improperFraction = isProperFraction(5, 2);
42-
assertEquals(improperFraction, false);
43-
44-
// Negative Fraction check:
45-
// Input: numerator = -4, denominator = 7
46-
// target output: true
47-
// Explanation: The fraction -4/7 is a proper fraction because the absolute value of the numerator (4) is less than the denominator (7). The function should return true.
48-
const negativeFraction = isProperFraction(-4, 7);
49-
// ====> complete with your assertion
50-
51-
// Equal Numerator and Denominator check:
52-
// Input: numerator = 3, denominator = 3
53-
// target output: false
54-
// Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false.
55-
const equalFraction = isProperFraction(3, 3);
56-
// ====> complete with your assertion
57-
58-
// Stretch:
59-
// What other scenarios could you test for?
32+
// Example: 1/2 is a proper fraction
33+
assertEquals(isProperFraction(1, 2), true);

0 commit comments

Comments
 (0)