From 2b5f14cf6979706d394a7699aa00f2b5e9d02bbb Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Mon, 31 Jan 2022 16:37:54 -0500
Subject: [PATCH 01/74] Require Hello World in the document
---
src/text.Test.tsx | 9 +++++++++
1 file changed, 9 insertions(+)
create mode 100644 src/text.Test.tsx
diff --git a/src/text.Test.tsx b/src/text.Test.tsx
new file mode 100644
index 0000000000..b32c330d3f
--- /dev/null
+++ b/src/text.Test.tsx
@@ -0,0 +1,9 @@
+import React from "react";
+import { render, screen } from "@testing-library/react";
+import App from "./App";
+
+test("renders the text 'Hello World' somewhere", () => {
+ render();
+ const text = screen.getByText(/Hello World/);
+ expect(text).toBeInTheDocument();
+});
From a7dee05e0bee0379110c6189433d12482280146a Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Mon, 31 Jan 2022 16:41:17 -0500
Subject: [PATCH 02/74] Rename text.Test.tsx to text.test.tsx
---
src/{text.Test.tsx => text.test.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename src/{text.Test.tsx => text.test.tsx} (100%)
diff --git a/src/text.Test.tsx b/src/text.test.tsx
similarity index 100%
rename from src/text.Test.tsx
rename to src/text.test.tsx
From 3e381f38b1d44afd102eb053a8ba9a48a069434e Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Mon, 31 Jan 2022 16:56:42 -0500
Subject: [PATCH 03/74] Include the task info
---
public/tasks/task-first-branch.md | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 public/tasks/task-first-branch.md
diff --git a/public/tasks/task-first-branch.md b/public/tasks/task-first-branch.md
new file mode 100644
index 0000000000..94333338a0
--- /dev/null
+++ b/public/tasks/task-first-branch.md
@@ -0,0 +1,5 @@
+# Task - First Branch
+
+Version: 0.0.1
+
+Pass a short test to have certain text on the page.
From e6b1dab1961daf6f03459789cef974bf043501f2 Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Thu, 3 Feb 2022 14:10:55 -0500
Subject: [PATCH 04/74] Allow one or more instances of the Hello World text
---
src/text.test.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/text.test.tsx b/src/text.test.tsx
index b32c330d3f..f99a063e76 100644
--- a/src/text.test.tsx
+++ b/src/text.test.tsx
@@ -4,6 +4,6 @@ import App from "./App";
test("renders the text 'Hello World' somewhere", () => {
render();
- const text = screen.getByText(/Hello World/);
- expect(text).toBeInTheDocument();
+ const texts = screen.getAllByText(/Hello World/);
+ expect(texts.length).toBeGreaterThanOrEqual(1);
});
From 7a207345d9e404afd04607811b89bb758de02905 Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Sat, 24 Aug 2024 12:52:12 -0400
Subject: [PATCH 05/74] Include json test command here
---
package.json | 1 +
1 file changed, 1 insertion(+)
diff --git a/package.json b/package.json
index cf6e1bc772..fc2b66a549 100644
--- a/package.json
+++ b/package.json
@@ -20,6 +20,7 @@
"build": "react-scripts build",
"test": "react-scripts test",
"test:cov": "react-scripts test --coverage --watchAll",
+ "test:json": "react-scripts test --json --watchAll=false --outputFile jest-output.json --coverage",
"eject": "react-scripts eject",
"lint": "eslint ./src --ext .tsx --ext .ts --max-warnings 0",
"eslint-output": "eslint-output ./src --ext .tsx --ext .ts --max-warnings 0",
From 7fe9ca316fad2e694586e037fe601b85a2584c56 Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Mon, 31 Jan 2022 16:37:54 -0500
Subject: [PATCH 06/74] Require Hello World in the document
---
src/text.Test.tsx | 9 +++++++++
1 file changed, 9 insertions(+)
create mode 100644 src/text.Test.tsx
diff --git a/src/text.Test.tsx b/src/text.Test.tsx
new file mode 100644
index 0000000000..b32c330d3f
--- /dev/null
+++ b/src/text.Test.tsx
@@ -0,0 +1,9 @@
+import React from "react";
+import { render, screen } from "@testing-library/react";
+import App from "./App";
+
+test("renders the text 'Hello World' somewhere", () => {
+ render();
+ const text = screen.getByText(/Hello World/);
+ expect(text).toBeInTheDocument();
+});
From b8b8878c873d4faa2fd5f04d656e23d66c7d6cef Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Mon, 31 Jan 2022 16:56:42 -0500
Subject: [PATCH 07/74] Include the task info
---
public/tasks/task-first-branch.md | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 public/tasks/task-first-branch.md
diff --git a/public/tasks/task-first-branch.md b/public/tasks/task-first-branch.md
new file mode 100644
index 0000000000..94333338a0
--- /dev/null
+++ b/public/tasks/task-first-branch.md
@@ -0,0 +1,5 @@
+# Task - First Branch
+
+Version: 0.0.1
+
+Pass a short test to have certain text on the page.
From fbdebdec2006b01d3976bd9408037baf82eb5e56 Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Mon, 31 Jan 2022 16:41:17 -0500
Subject: [PATCH 08/74] Rename text.Test.tsx to text.test.tsx
---
src/{text.Test.tsx => text.test.tsx} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename src/{text.Test.tsx => text.test.tsx} (100%)
diff --git a/src/text.Test.tsx b/src/text.test.tsx
similarity index 100%
rename from src/text.Test.tsx
rename to src/text.test.tsx
From 2f0146c22beca5c5ac48603876f0fa8ea2e2e905 Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Thu, 3 Feb 2022 14:10:55 -0500
Subject: [PATCH 09/74] Allow one or more instances of the Hello World text
---
src/text.test.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/text.test.tsx b/src/text.test.tsx
index b32c330d3f..f99a063e76 100644
--- a/src/text.test.tsx
+++ b/src/text.test.tsx
@@ -4,6 +4,6 @@ import App from "./App";
test("renders the text 'Hello World' somewhere", () => {
render();
- const text = screen.getByText(/Hello World/);
- expect(text).toBeInTheDocument();
+ const texts = screen.getAllByText(/Hello World/);
+ expect(texts.length).toBeGreaterThanOrEqual(1);
});
From ac36b32302a8ea2e66b4b954626c8e396e172075 Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Sat, 29 Jan 2022 23:59:24 -0500
Subject: [PATCH 10/74] First set of tests
---
public/tasks/task-html-css.md | 5 +++++
src/HtmlCss.test.tsx | 28 ++++++++++++++++++++++++++++
2 files changed, 33 insertions(+)
create mode 100644 public/tasks/task-html-css.md
create mode 100644 src/HtmlCss.test.tsx
diff --git a/public/tasks/task-html-css.md b/public/tasks/task-html-css.md
new file mode 100644
index 0000000000..ebc0efcba5
--- /dev/null
+++ b/public/tasks/task-html-css.md
@@ -0,0 +1,5 @@
+# Task - HTML/CSS
+
+Version: 0.0.1
+
+Add in some HTML and CSS, including a fancy looking button.
diff --git a/src/HtmlCss.test.tsx b/src/HtmlCss.test.tsx
new file mode 100644
index 0000000000..168ce37fde
--- /dev/null
+++ b/src/HtmlCss.test.tsx
@@ -0,0 +1,28 @@
+import React from "react";
+import { render, screen } from "@testing-library/react";
+import App from "./App";
+
+describe("Some HTML Elements are added.", () => {
+ test("There is a header", () => {
+ render();
+ const header = screen.getByRole("heading");
+ expect(header).toBeInTheDocument();
+ });
+});
+
+describe("Some basic CSS is added.", () => {
+ test("There is a floating red box", () => {
+ render();
+ expect(true);
+ });
+});
+
+describe("Some Bootstrap Elements are added", () => {
+ test("There is a bootstrap button", () => {
+ render();
+ const button = screen.getByRole("button");
+ expect(button).toBeInTheDocument();
+ expect(button).toHaveClass("btn");
+ expect(button).toHaveClass("btn-primary");
+ });
+});
From d04739d1d2ec0c934c0ecf1dc05ac1289063627d Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Sun, 30 Jan 2022 00:24:38 -0500
Subject: [PATCH 11/74] Some logging tests
---
src/HtmlCss.test.tsx | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/HtmlCss.test.tsx b/src/HtmlCss.test.tsx
index 168ce37fde..bf957616f9 100644
--- a/src/HtmlCss.test.tsx
+++ b/src/HtmlCss.test.tsx
@@ -1,6 +1,7 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import App from "./App";
+import userEvent from "@testing-library/user-event";
describe("Some HTML Elements are added.", () => {
test("There is a header", () => {
@@ -18,11 +19,25 @@ describe("Some basic CSS is added.", () => {
});
describe("Some Bootstrap Elements are added", () => {
- test("There is a bootstrap button", () => {
+ test("There is one bootstrap button with the text 'Log Hello World'", () => {
render();
- const button = screen.getByRole("button");
+ const button = screen.getByRole("button", { name: /Log Hello World/i });
expect(button).toBeInTheDocument();
expect(button).toHaveClass("btn");
expect(button).toHaveClass("btn-primary");
});
+
+ test("Not clicking the bootstrap button does not logs 'Hello World!'", () => {
+ const consoleSpy = jest.spyOn(console, "log");
+ render();
+ expect(consoleSpy).not.toHaveBeenCalledWith("Hello World!");
+ });
+
+ test("Clicking the bootstrap button logs 'Hello World!'", () => {
+ const consoleSpy = jest.spyOn(console, "log");
+ render();
+ const button = screen.getByRole("button", { name: /Log Hello World/i });
+ userEvent.click(button);
+ expect(consoleSpy).toHaveBeenCalledWith("Hello World!");
+ });
});
From b26100f543943eced73fdff33784861243c65386 Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Sun, 30 Jan 2022 00:47:43 -0500
Subject: [PATCH 12/74] More html tests
---
src/HtmlCss.test.tsx | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/HtmlCss.test.tsx b/src/HtmlCss.test.tsx
index bf957616f9..676c37f903 100644
--- a/src/HtmlCss.test.tsx
+++ b/src/HtmlCss.test.tsx
@@ -9,6 +9,20 @@ describe("Some HTML Elements are added.", () => {
const header = screen.getByRole("heading");
expect(header).toBeInTheDocument();
});
+
+ test("There is an image with alt text", () => {
+ render();
+ const image = screen.getByRole("image");
+ expect(image).toBeInTheDocument();
+ expect(image).toHaveAttribute("alt");
+ });
+
+ test("There is a list with at least three elements", () => {
+ render();
+ const list = screen.getByRole("list");
+ expect(list).toBeInTheDocument();
+ expect(list.children.length).toBeGreaterThanOrEqual(3);
+ });
});
describe("Some basic CSS is added.", () => {
From 3bf4550a8f042dee28a57c06abec05dfce779519 Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Sun, 30 Jan 2022 00:55:24 -0500
Subject: [PATCH 13/74] Fix the image test
---
src/HtmlCss.test.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/HtmlCss.test.tsx b/src/HtmlCss.test.tsx
index 676c37f903..79b7db2dda 100644
--- a/src/HtmlCss.test.tsx
+++ b/src/HtmlCss.test.tsx
@@ -12,7 +12,7 @@ describe("Some HTML Elements are added.", () => {
test("There is an image with alt text", () => {
render();
- const image = screen.getByRole("image");
+ const image = screen.getByRole("img");
expect(image).toBeInTheDocument();
expect(image).toHaveAttribute("alt");
});
From 8dff2b64a2efc0b1b49703077965fe5e334eab1a Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Mon, 31 Jan 2022 16:31:58 -0500
Subject: [PATCH 14/74] Updated CSS tests, left a note about additional tests
---
src/HtmlCss.test.tsx | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/HtmlCss.test.tsx b/src/HtmlCss.test.tsx
index 79b7db2dda..379fc8f449 100644
--- a/src/HtmlCss.test.tsx
+++ b/src/HtmlCss.test.tsx
@@ -30,6 +30,14 @@ describe("Some basic CSS is added.", () => {
render();
expect(true);
});
+
+ test("The background color of the header area is different", () => {
+ render();
+ const banner = screen.getByRole("banner");
+ expect(banner).not.toHaveStyle({
+ "background-color": "rgb(40, 44, 52)"
+ });
+ });
});
describe("Some Bootstrap Elements are added", () => {
From b66d4de909f74de4cba160a6fff05b078b9b47cc Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Mon, 31 Jan 2022 16:32:13 -0500
Subject: [PATCH 15/74] See previous commit message
---
src/HtmlCss.test.tsx | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/HtmlCss.test.tsx b/src/HtmlCss.test.tsx
index 379fc8f449..36767ad350 100644
--- a/src/HtmlCss.test.tsx
+++ b/src/HtmlCss.test.tsx
@@ -26,11 +26,6 @@ describe("Some HTML Elements are added.", () => {
});
describe("Some basic CSS is added.", () => {
- test("There is a floating red box", () => {
- render();
- expect(true);
- });
-
test("The background color of the header area is different", () => {
render();
const banner = screen.getByRole("banner");
@@ -63,3 +58,7 @@ describe("Some Bootstrap Elements are added", () => {
expect(consoleSpy).toHaveBeenCalledWith("Hello World!");
});
});
+
+/**
+ * Remember, there are additional tasks described on the page!
+ */
From 0a24364f67b1ee221ebe175d6c494d5eca6ad7dc Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Sat, 24 Aug 2024 13:10:09 -0400
Subject: [PATCH 16/74] Add in new css test
---
src/HtmlCss.test.tsx | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/src/HtmlCss.test.tsx b/src/HtmlCss.test.tsx
index 36767ad350..48b0a6df2d 100644
--- a/src/HtmlCss.test.tsx
+++ b/src/HtmlCss.test.tsx
@@ -30,7 +30,7 @@ describe("Some basic CSS is added.", () => {
render();
const banner = screen.getByRole("banner");
expect(banner).not.toHaveStyle({
- "background-color": "rgb(40, 44, 52)"
+ "background-color": "rgb(40, 44, 52)",
});
});
});
@@ -59,6 +59,25 @@ describe("Some Bootstrap Elements are added", () => {
});
});
-/**
- * Remember, there are additional tasks described on the page!
- */
+describe("Some additional CSS was added", () => {
+ test("checks if any element has a background color of red", () => {
+ const { container } = render();
+ // Get all elements in the rendered container
+ const elements = container.querySelectorAll("*");
+
+ // Check if any element has a background color of red
+ let foundRedBackground = false;
+
+ elements.forEach((element) => {
+ const style = getComputedStyle(element);
+ if (
+ style.backgroundColor === "red" ||
+ style.backgroundColor === "rgb(255, 0, 0)"
+ ) {
+ foundRedBackground = true;
+ }
+ });
+
+ expect(foundRedBackground).toBe(true);
+ });
+});
From 4d43d7a5d133522b0a8d92e1cb3d7e4053a81992 Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Sat, 24 Aug 2024 13:12:28 -0400
Subject: [PATCH 17/74] Add in points
---
src/HtmlCss.test.tsx | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/HtmlCss.test.tsx b/src/HtmlCss.test.tsx
index 48b0a6df2d..320cb97524 100644
--- a/src/HtmlCss.test.tsx
+++ b/src/HtmlCss.test.tsx
@@ -4,20 +4,20 @@ import App from "./App";
import userEvent from "@testing-library/user-event";
describe("Some HTML Elements are added.", () => {
- test("There is a header", () => {
+ test("(2 pts) There is a header", () => {
render();
const header = screen.getByRole("heading");
expect(header).toBeInTheDocument();
});
- test("There is an image with alt text", () => {
+ test("(2 pts) There is an image with alt text", () => {
render();
const image = screen.getByRole("img");
expect(image).toBeInTheDocument();
expect(image).toHaveAttribute("alt");
});
- test("There is a list with at least three elements", () => {
+ test("(2 pts) There is a list with at least three elements", () => {
render();
const list = screen.getByRole("list");
expect(list).toBeInTheDocument();
@@ -25,7 +25,7 @@ describe("Some HTML Elements are added.", () => {
});
});
-describe("Some basic CSS is added.", () => {
+describe("(2 pts) Some basic CSS is added.", () => {
test("The background color of the header area is different", () => {
render();
const banner = screen.getByRole("banner");
@@ -35,7 +35,7 @@ describe("Some basic CSS is added.", () => {
});
});
-describe("Some Bootstrap Elements are added", () => {
+describe("(2 pts) Some Bootstrap Elements are added", () => {
test("There is one bootstrap button with the text 'Log Hello World'", () => {
render();
const button = screen.getByRole("button", { name: /Log Hello World/i });
@@ -44,13 +44,13 @@ describe("Some Bootstrap Elements are added", () => {
expect(button).toHaveClass("btn-primary");
});
- test("Not clicking the bootstrap button does not logs 'Hello World!'", () => {
+ test("(2 pts) Not clicking the bootstrap button does not logs 'Hello World!'", () => {
const consoleSpy = jest.spyOn(console, "log");
render();
expect(consoleSpy).not.toHaveBeenCalledWith("Hello World!");
});
- test("Clicking the bootstrap button logs 'Hello World!'", () => {
+ test("(2 pts) Clicking the bootstrap button logs 'Hello World!'", () => {
const consoleSpy = jest.spyOn(console, "log");
render();
const button = screen.getByRole("button", { name: /Log Hello World/i });
@@ -60,7 +60,7 @@ describe("Some Bootstrap Elements are added", () => {
});
describe("Some additional CSS was added", () => {
- test("checks if any element has a background color of red", () => {
+ test("(2 pts) checks if any element has a background color of red", () => {
const { container } = render();
// Get all elements in the rendered container
const elements = container.querySelectorAll("*");
From 83c4461f9dbe7d2a66c09eed18959565a302eea2 Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Sat, 29 Jan 2022 23:23:45 -0500
Subject: [PATCH 18/74] Basic functions tests and stubs
---
public/tasks/task-functions.md | 5 +++
src/functions.test.ts | 59 ++++++++++++++++++++++++++++++++++
src/functions.ts | 19 +++++++++++
3 files changed, 83 insertions(+)
create mode 100644 public/tasks/task-functions.md
create mode 100644 src/functions.test.ts
create mode 100644 src/functions.ts
diff --git a/public/tasks/task-functions.md b/public/tasks/task-functions.md
new file mode 100644
index 0000000000..36e7926bb7
--- /dev/null
+++ b/public/tasks/task-functions.md
@@ -0,0 +1,5 @@
+# Task - Functions
+
+Version: 0.0.1
+
+Implement a bunch of functions that work on primitives.
diff --git a/src/functions.test.ts b/src/functions.test.ts
new file mode 100644
index 0000000000..e0bef414ea
--- /dev/null
+++ b/src/functions.test.ts
@@ -0,0 +1,59 @@
+import {
+ add3,
+ fahrenheitToCelius,
+ shout,
+ isQuestion,
+ convertYesNo
+} from "./functions";
+
+test("Testing the basic functions", () => {
+ it("Testing the add3 function", () => {
+ expect(add3(1, 2, 3)).toBe(6);
+ expect(add3(9, 7, 4)).toBe(20);
+ expect(add3(6, -3, 9)).toBe(15);
+ expect(add3(10, 1, -9)).toBe(11);
+ expect(add3(-9, -100, -4)).toBe(0);
+ expect(add3(-1, -1, 1)).toBe(1);
+ });
+
+ it("Testing the fahrenheitToCelius function", () => {
+ expect(fahrenheitToCelius(32)).toBe(0);
+ expect(fahrenheitToCelius(-40)).toBe(40);
+ expect(fahrenheitToCelius(-22)).toBe(-30);
+ expect(fahrenheitToCelius(14)).toBe(-10);
+ expect(fahrenheitToCelius(68)).toBe(20);
+ expect(fahrenheitToCelius(86)).toBe(30);
+ expect(fahrenheitToCelius(212)).toBe(100);
+ });
+
+ it("Testing the shout function", () => {
+ expect(shout("Hello")).toBe("HELLO!");
+ expect(shout("What?")).toBe("WHAT?!");
+ expect(shout("oHo")).toBe("OHO!");
+ expect(shout("AHHHH!!!")).toBe("AHHHH!!!!");
+ expect(shout("")).toBe("!");
+ expect(shout("Please go outside")).toBe("PLEASE GO OUTSIDE!");
+ });
+
+ it("Testing the isQuestion function", () => {
+ expect(isQuestion("Is this a question?")).toBe(true);
+ expect(isQuestion("Who are you?")).toBe(true);
+ expect(isQuestion("WHAT ARE YOU !?")).toBe(true);
+ expect(isQuestion("WHAT IS THIS?!")).toBe(false);
+ expect(isQuestion("OH GOD!")).toBe(false);
+ expect(isQuestion("Oh nevermind, it's fine.")).toBe(false);
+ expect(isQuestion("")).toBe(false);
+ });
+
+ it("Testing the convertYesNo function", () => {
+ expect(convertYesNo("yes")).toBe(true);
+ expect(convertYesNo("YES")).toBe(true);
+ expect(convertYesNo("NO")).toBe(false);
+ expect(convertYesNo("no")).toBe(false);
+ expect(convertYesNo("Apple")).toBe(null);
+ expect(convertYesNo("Bananas")).toBe(null);
+ expect(convertYesNo("Nope")).toBe(null);
+ expect(convertYesNo("Yesterday")).toBe(null);
+ expect(convertYesNo("Maybe")).toBe(null);
+ });
+});
diff --git a/src/functions.ts b/src/functions.ts
new file mode 100644
index 0000000000..03193e4212
--- /dev/null
+++ b/src/functions.ts
@@ -0,0 +1,19 @@
+export function fahrenheitToCelius(temperature: number): number {
+ return 0;
+}
+
+export function add3(first: number, second: number, third: number): number {
+ return 0;
+}
+
+export function shout(message: string): string {
+ return "";
+}
+
+export function isQuestion(message: string): boolean {
+ return true;
+}
+
+export function convertYesNo(word: string): boolean | null {
+ return true;
+}
From a48653022ec3c8b7ce99cf49d98b041e20815420 Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Sat, 29 Jan 2022 23:30:17 -0500
Subject: [PATCH 19/74] Fix test organization
---
src/functions.test.ts | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/functions.test.ts b/src/functions.test.ts
index e0bef414ea..98c926bb6f 100644
--- a/src/functions.test.ts
+++ b/src/functions.test.ts
@@ -6,8 +6,8 @@ import {
convertYesNo
} from "./functions";
-test("Testing the basic functions", () => {
- it("Testing the add3 function", () => {
+describe("Testing the basic functions", () => {
+ test("Testing the add3 function", () => {
expect(add3(1, 2, 3)).toBe(6);
expect(add3(9, 7, 4)).toBe(20);
expect(add3(6, -3, 9)).toBe(15);
@@ -16,7 +16,7 @@ test("Testing the basic functions", () => {
expect(add3(-1, -1, 1)).toBe(1);
});
- it("Testing the fahrenheitToCelius function", () => {
+ test("Testing the fahrenheitToCelius function", () => {
expect(fahrenheitToCelius(32)).toBe(0);
expect(fahrenheitToCelius(-40)).toBe(40);
expect(fahrenheitToCelius(-22)).toBe(-30);
@@ -26,7 +26,7 @@ test("Testing the basic functions", () => {
expect(fahrenheitToCelius(212)).toBe(100);
});
- it("Testing the shout function", () => {
+ test("Testing the shout function", () => {
expect(shout("Hello")).toBe("HELLO!");
expect(shout("What?")).toBe("WHAT?!");
expect(shout("oHo")).toBe("OHO!");
@@ -35,7 +35,7 @@ test("Testing the basic functions", () => {
expect(shout("Please go outside")).toBe("PLEASE GO OUTSIDE!");
});
- it("Testing the isQuestion function", () => {
+ test("Testing the isQuestion function", () => {
expect(isQuestion("Is this a question?")).toBe(true);
expect(isQuestion("Who are you?")).toBe(true);
expect(isQuestion("WHAT ARE YOU !?")).toBe(true);
@@ -45,7 +45,7 @@ test("Testing the basic functions", () => {
expect(isQuestion("")).toBe(false);
});
- it("Testing the convertYesNo function", () => {
+ test("Testing the convertYesNo function", () => {
expect(convertYesNo("yes")).toBe(true);
expect(convertYesNo("YES")).toBe(true);
expect(convertYesNo("NO")).toBe(false);
From 9722564e99cecda5d50dd95524c94a76c4cda923 Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Sat, 29 Jan 2022 23:39:22 -0500
Subject: [PATCH 20/74] Fix issue in fahrenheit conversion
---
src/functions.test.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/functions.test.ts b/src/functions.test.ts
index 98c926bb6f..3eb9f4f3aa 100644
--- a/src/functions.test.ts
+++ b/src/functions.test.ts
@@ -18,7 +18,7 @@ describe("Testing the basic functions", () => {
test("Testing the fahrenheitToCelius function", () => {
expect(fahrenheitToCelius(32)).toBe(0);
- expect(fahrenheitToCelius(-40)).toBe(40);
+ expect(fahrenheitToCelius(-40)).toBe(-40);
expect(fahrenheitToCelius(-22)).toBe(-30);
expect(fahrenheitToCelius(14)).toBe(-10);
expect(fahrenheitToCelius(68)).toBe(20);
From bd06d5d0e3ed264f7bffb4e8e4811d0efc170255 Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Thu, 3 Feb 2022 14:27:08 -0500
Subject: [PATCH 21/74] Move around some of the functions
---
src/functions.test.ts | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/functions.test.ts b/src/functions.test.ts
index 3eb9f4f3aa..c496ac7e99 100644
--- a/src/functions.test.ts
+++ b/src/functions.test.ts
@@ -7,15 +7,6 @@ import {
} from "./functions";
describe("Testing the basic functions", () => {
- test("Testing the add3 function", () => {
- expect(add3(1, 2, 3)).toBe(6);
- expect(add3(9, 7, 4)).toBe(20);
- expect(add3(6, -3, 9)).toBe(15);
- expect(add3(10, 1, -9)).toBe(11);
- expect(add3(-9, -100, -4)).toBe(0);
- expect(add3(-1, -1, 1)).toBe(1);
- });
-
test("Testing the fahrenheitToCelius function", () => {
expect(fahrenheitToCelius(32)).toBe(0);
expect(fahrenheitToCelius(-40)).toBe(-40);
@@ -26,6 +17,15 @@ describe("Testing the basic functions", () => {
expect(fahrenheitToCelius(212)).toBe(100);
});
+ test("Testing the add3 function", () => {
+ expect(add3(1, 2, 3)).toBe(6);
+ expect(add3(9, 7, 4)).toBe(20);
+ expect(add3(6, -3, 9)).toBe(15);
+ expect(add3(10, 1, -9)).toBe(11);
+ expect(add3(-9, -100, -4)).toBe(0);
+ expect(add3(-1, -1, 1)).toBe(1);
+ });
+
test("Testing the shout function", () => {
expect(shout("Hello")).toBe("HELLO!");
expect(shout("What?")).toBe("WHAT?!");
From 4cd1900783f690690229b7c17cf9e81995f52b3a Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Thu, 3 Feb 2022 14:27:18 -0500
Subject: [PATCH 22/74] Explain what the actual functions require you to do
---
src/functions.ts | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/src/functions.ts b/src/functions.ts
index 03193e4212..e614c81c0c 100644
--- a/src/functions.ts
+++ b/src/functions.ts
@@ -1,19 +1,41 @@
+/**
+ * Consumes a single temperature in Fahrenheit (a number) and converts to Celsius
+ * using this formula:
+ * C = (F - 32) * 5/9
+ */
export function fahrenheitToCelius(temperature: number): number {
return 0;
}
+/**
+ * Consumes three numbers and produces their sum. BUT you should only add a number
+ * if the number is greater than zero.
+ */
export function add3(first: number, second: number, third: number): number {
return 0;
}
+/**
+ * Consumes a string and produces the same string in UPPERCASE and with an exclamation
+ * mark added to the end.
+ */
export function shout(message: string): string {
return "";
}
+/**
+ * Consumes a string (a message) and returns a boolean if the string ends in a question
+ * mark. Do not use an `if` statement in solving this question.
+ */
export function isQuestion(message: string): boolean {
return true;
}
+/**
+ * Consumes a word (a string) and returns either `true`, `false`, or `null`. If the string
+ * is "yes" (upper or lower case), then return `true`. If the string is "no" (again, either
+ * upper or lower case), then return `false`. Otherwise, return `null`.
+ */
export function convertYesNo(word: string): boolean | null {
return true;
}
From cf1d21a31d00c2e8dc8bb7c76f372b3e0adebfbe Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Sat, 24 Aug 2024 13:15:59 -0400
Subject: [PATCH 23/74] Update formatting
---
src/functions.test.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/functions.test.ts b/src/functions.test.ts
index c496ac7e99..a082bfd61a 100644
--- a/src/functions.test.ts
+++ b/src/functions.test.ts
@@ -3,7 +3,7 @@ import {
fahrenheitToCelius,
shout,
isQuestion,
- convertYesNo
+ convertYesNo,
} from "./functions";
describe("Testing the basic functions", () => {
From e11693a366f61cdb442c6f6f5822bd49e2dd604f Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Sat, 24 Aug 2024 13:18:24 -0400
Subject: [PATCH 24/74] Add in points
---
src/functions.test.ts | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/functions.test.ts b/src/functions.test.ts
index a082bfd61a..3d921f5d64 100644
--- a/src/functions.test.ts
+++ b/src/functions.test.ts
@@ -7,7 +7,7 @@ import {
} from "./functions";
describe("Testing the basic functions", () => {
- test("Testing the fahrenheitToCelius function", () => {
+ test("(3 pts) Testing the fahrenheitToCelius function", () => {
expect(fahrenheitToCelius(32)).toBe(0);
expect(fahrenheitToCelius(-40)).toBe(-40);
expect(fahrenheitToCelius(-22)).toBe(-30);
@@ -17,7 +17,7 @@ describe("Testing the basic functions", () => {
expect(fahrenheitToCelius(212)).toBe(100);
});
- test("Testing the add3 function", () => {
+ test("(3 pts) Testing the add3 function", () => {
expect(add3(1, 2, 3)).toBe(6);
expect(add3(9, 7, 4)).toBe(20);
expect(add3(6, -3, 9)).toBe(15);
@@ -26,7 +26,7 @@ describe("Testing the basic functions", () => {
expect(add3(-1, -1, 1)).toBe(1);
});
- test("Testing the shout function", () => {
+ test("(3 pts) Testing the shout function", () => {
expect(shout("Hello")).toBe("HELLO!");
expect(shout("What?")).toBe("WHAT?!");
expect(shout("oHo")).toBe("OHO!");
@@ -35,7 +35,7 @@ describe("Testing the basic functions", () => {
expect(shout("Please go outside")).toBe("PLEASE GO OUTSIDE!");
});
- test("Testing the isQuestion function", () => {
+ test("(3 pts) Testing the isQuestion function", () => {
expect(isQuestion("Is this a question?")).toBe(true);
expect(isQuestion("Who are you?")).toBe(true);
expect(isQuestion("WHAT ARE YOU !?")).toBe(true);
@@ -45,7 +45,7 @@ describe("Testing the basic functions", () => {
expect(isQuestion("")).toBe(false);
});
- test("Testing the convertYesNo function", () => {
+ test("(3 pts) Testing the convertYesNo function", () => {
expect(convertYesNo("yes")).toBe(true);
expect(convertYesNo("YES")).toBe(true);
expect(convertYesNo("NO")).toBe(false);
From 7cc4e3f20e61307e9f22eb466fe21871b3eefbd3 Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Tue, 1 Feb 2022 14:51:32 -0500
Subject: [PATCH 25/74] First stab at array problems
---
public/tasks/task-arrays.md | 5 +++
src/arrays.test.ts | 12 ++++++
src/arrays.ts | 84 +++++++++++++++++++++++++++++++++++++
3 files changed, 101 insertions(+)
create mode 100644 public/tasks/task-arrays.md
create mode 100644 src/arrays.test.ts
create mode 100644 src/arrays.ts
diff --git a/public/tasks/task-arrays.md b/public/tasks/task-arrays.md
new file mode 100644
index 0000000000..c2fbf80f8d
--- /dev/null
+++ b/public/tasks/task-arrays.md
@@ -0,0 +1,5 @@
+# Task - Arrays
+
+Version: 0.0.1
+
+Implement functions that work with arrays immutably.
diff --git a/src/arrays.test.ts b/src/arrays.test.ts
new file mode 100644
index 0000000000..b812349d2f
--- /dev/null
+++ b/src/arrays.test.ts
@@ -0,0 +1,12 @@
+import { bookEndList } from "./arrays";
+
+describe("Testing the array functions", () => {
+ const NUMBERS_1 = [1, 2, 3];
+
+ test("Testing the bookEndList function", () => {
+ // Ensure that the original array was not changed
+ expect(bookEndList(NUMBERS_1)).not.toBe(NUMBERS_1);
+ // And that a correct new array was returned
+ expect(bookEndList(NUMBERS_1)).toEqual([1, 3]);
+ });
+});
diff --git a/src/arrays.ts b/src/arrays.ts
new file mode 100644
index 0000000000..7604b40cdb
--- /dev/null
+++ b/src/arrays.ts
@@ -0,0 +1,84 @@
+/**
+ * Consume an array of numbers, and return a new array containing
+ * JUST the first and last number. If there are no elements, return
+ * an empty array. If there is one element, the resulting list should
+ * the number twice.
+ */
+export function bookEndList(numbers: number[]): number[] {
+ return numbers;
+}
+
+/**
+ * Consume an array of numbers, and return a new array where each
+ * number has been tripled (multiplied by 3).
+ */
+export function tripleNumbers(numbers: number[]): number[] {
+ return numbers;
+}
+
+/**
+ * Consume an array of strings and convert them to integers. If
+ * the number cannot be parsed as an integer, convert it to "?" instead.
+ */
+export function stringsToIntegers(numbers: string[]): number[] {
+ return [];
+}
+
+/**
+ * Consume an array of strings and return them as numbers. Note that
+ * the strings MAY have "$" symbols at the beginning, in which case
+ * those should be removed. If the result cannot be parsed as an integer,
+ * convert it to "?" instead.
+ */
+// Remember, you can write functions as lambdas too! They work exactly the same.
+export const removeDollars = (amounts: string[]): number[] => {
+ return [];
+};
+
+/**
+ * Consume an array of messages and return a new list of the messages. However, any
+ * string that ends in "!" should be made uppercase.
+ */
+export const shoutIfExclaiming = (messages: string[]): string[] => {
+ return [];
+};
+
+/**
+ * Consumes an array of words and returns the number of words that are LESS THAN
+ * 4 letters long.
+ */
+export function countShortWords(words: string[]): number {
+ return 0;
+}
+
+/**
+ * Consumes an array of colors (e.g., 'red', 'purple') and returns true if ALL
+ * the colors are either 'red', 'blue', or 'green'. If an empty list is given,
+ * then return true.
+ */
+export function allRGB(colors: string[]): boolean {
+ return false;
+}
+
+/**
+ * Consumes an array of numbers, and produces a string representation of the
+ * numbers being added together along with their actual sum.
+ *
+ * For instance, the array [1, 2, 3] would become "6=1+2+3".
+ */
+export function makeMath(addends: number[]): string {
+ return "";
+}
+
+/**
+ * Consumes an array of numbers and produces a new array of the same numbers,
+ * with one difference. After the FIRST negative number, insert the sum of all
+ * previous numbers in the list. If there are no negative numbers, then append
+ * 0 to the list.
+ *
+ * For instance, the array [1, 9, -5, 7] would become [1, 9, -5, 10, 7]
+ * And the array [1, 9, 7] would become [1, 9, 0]
+ */
+export function injectPositive(values: number[]): number[] {
+ return [];
+}
From f25333778032fc42866a278af6a3ce871f735150 Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Tue, 1 Feb 2022 16:09:10 -0500
Subject: [PATCH 26/74] Add in the rest of the tests
---
src/arrays.test.ts | 269 ++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 265 insertions(+), 4 deletions(-)
diff --git a/src/arrays.test.ts b/src/arrays.test.ts
index b812349d2f..0881d9fe8a 100644
--- a/src/arrays.test.ts
+++ b/src/arrays.test.ts
@@ -1,12 +1,273 @@
-import { bookEndList } from "./arrays";
+import {
+ allRGB,
+ bookEndList,
+ countShortWords,
+ injectPositive,
+ makeMath,
+ removeDollars,
+ shoutIfExclaiming,
+ stringsToIntegers,
+ tripleNumbers
+} from "./arrays";
describe("Testing the array functions", () => {
+ //////////////////////////////////
+ // bookEndList and tripleNumbers
+
const NUMBERS_1 = [1, 2, 3];
+ const NUMBERS_2 = [100, 300, 200];
+ const NUMBERS_3 = [5];
+ const NUMBERS_4: number[] = [];
+ const NUMBERS_5 = [100, 199, 1, -5, 7, 3];
+ const NUMBERS_6 = [-100, -200, 100, 200];
+ const NUMBERS_7 = [199, 1, 550, 50, 200];
+
+ // Ensure that none of the arrays were changed mutably
+ // If you fail these, you aren't using map/filter/reduce/etc. properly!
+ afterEach(() => {
+ expect(NUMBERS_1).toEqual([1, 2, 3]);
+ expect(NUMBERS_2).toEqual([100, 300, 200]);
+ expect(NUMBERS_3).toEqual([5]);
+ expect(NUMBERS_4).toEqual([]);
+ expect(NUMBERS_5).toEqual([100, 199, 1, -5, 7, 3]);
+ expect(NUMBERS_6).toEqual([-100, -200, 100, 200]);
+ expect(NUMBERS_7).toEqual([199, 1, 550, 50, 200]);
+ });
test("Testing the bookEndList function", () => {
- // Ensure that the original array was not changed
- expect(bookEndList(NUMBERS_1)).not.toBe(NUMBERS_1);
- // And that a correct new array was returned
expect(bookEndList(NUMBERS_1)).toEqual([1, 3]);
+ expect(bookEndList(NUMBERS_2)).toEqual([100, 200]);
+ expect(bookEndList(NUMBERS_3)).toEqual([5, 5]);
+ expect(bookEndList(NUMBERS_4)).toEqual([]);
+ expect(bookEndList(NUMBERS_5)).toEqual([100, 3]);
+ expect(bookEndList(NUMBERS_6)).toEqual([-100, 200]);
+ });
+
+ test("Testing the tripleNumbers function", () => {
+ expect(tripleNumbers(NUMBERS_1)).toEqual([3, 6, 9]);
+ expect(tripleNumbers(NUMBERS_2)).toEqual([300, 900, 600]);
+ expect(tripleNumbers(NUMBERS_3)).toEqual([15]);
+ expect(tripleNumbers(NUMBERS_4)).toEqual([]);
+ expect(tripleNumbers(NUMBERS_5)).toEqual([300, 597, 3, -15, 21, 9]);
+ expect(tripleNumbers(NUMBERS_6)).toEqual([-300, -600, 300, 600]);
+ });
+
+ //////////////////////////////////
+ // stringsToIntegers
+
+ const VALUES_1 = ["1", "2", "3"];
+ const VALUES_2 = ["100", "200", "300"];
+ const VALUES_3 = ["5"];
+ const VALUES_4: string[] = [];
+ const VALUES_5 = ["100", "?", "27", "$44"];
+ const VALUES_6 = ["-1", "0", "1", "*1"];
+ const VALUES_7 = ["apple", "banana", "cactus"];
+
+ // Ensure that none of the arrays were changed mutably
+ // If you fail these, you aren't using map/filter/reduce/etc. properly!
+ afterEach(() => {
+ expect(VALUES_1).toEqual(["1", "2", "3"]);
+ expect(VALUES_2).toEqual(["100", "200", "300"]);
+ expect(VALUES_3).toEqual(["5"]);
+ expect(VALUES_4).toEqual([]);
+ expect(VALUES_5).toEqual(["100", "?", "27", "$44"]);
+ expect(VALUES_6).toEqual(["-1", "0", "1", "*1"]);
+ expect(VALUES_7).toEqual(["apple", "banana", "cactus"]);
+ });
+
+ test("Testing the stringsToIntegers function", () => {
+ expect(stringsToIntegers(VALUES_1)).toEqual([1, 2, 3]);
+ expect(stringsToIntegers(VALUES_2)).toEqual([100, 200, 300]);
+ expect(stringsToIntegers(VALUES_3)).toEqual([5]);
+ expect(stringsToIntegers(VALUES_4)).toEqual([]);
+ expect(stringsToIntegers(VALUES_5)).toEqual([100, 0, 27, 0]);
+ expect(stringsToIntegers(VALUES_6)).toEqual([-1, 0, 1, 0]);
+ expect(stringsToIntegers(VALUES_7)).toEqual([0, 0, 0]);
+ });
+
+ //////////////////////////////////
+ // removeDollars
+
+ const AMOUNTS_1 = ["$1", "$2", "$3"];
+ const AMOUNTS_2 = ["$100", "$200", "$300", "$400"];
+ const AMOUNTS_3 = ["$5"];
+ const AMOUNTS_4 = ["$"];
+ const AMOUNTS_5 = ["100", "200", "$300", "$400"];
+ const AMOUNTS_6: string[] = [];
+ const AMOUNTS_7 = ["100", "???", "7", "$233", "", "$"];
+ const AMOUNTS_8 = ["$one", "two", "$three"];
+
+ // Ensure that none of the arrays were changed mutably
+ // If you fail these, you aren't using map/filter/reduce/etc. properly!
+ afterEach(() => {
+ expect(AMOUNTS_1).toEqual(["$1", "$2", "$3"]);
+ expect(AMOUNTS_2).toEqual(["$100", "$200", "$300", "$400"]);
+ expect(AMOUNTS_3).toEqual(["$5"]);
+ expect(AMOUNTS_4).toEqual(["$"]);
+ expect(AMOUNTS_5).toEqual(["100", "200", "$300", "$400"]);
+ expect(AMOUNTS_6).toEqual([]);
+ expect(AMOUNTS_7).toEqual(["100", "???", "7", "$233", "", "$"]);
+ expect(AMOUNTS_8).toEqual(["$one", "two", "$three"]);
+ });
+
+ test("Testing the removeDollars function", () => {
+ expect(removeDollars(AMOUNTS_1)).toEqual([1, 2, 3]);
+ expect(removeDollars(AMOUNTS_2)).toEqual([100, 200, 300, 400]);
+ expect(removeDollars(AMOUNTS_3)).toEqual([5]);
+ expect(removeDollars(AMOUNTS_4)).toEqual([0]);
+ expect(removeDollars(AMOUNTS_5)).toEqual([100, 200, 300, 400]);
+ expect(removeDollars(AMOUNTS_6)).toEqual([]);
+ expect(removeDollars(AMOUNTS_7)).toEqual([100, 0, 7, 233, 0, 0]);
+ expect(removeDollars(AMOUNTS_8)).toEqual([0, 0, 0]);
+ });
+
+ //////////////////////////////////
+ // shoutIfExclaiming
+
+ const MESSAGE_1 = ["Hello", "you", "are", "great!"];
+ const MESSAGE_2 = ["oho!", "Oho!", "oHo!", "oHO!", "OHO!"];
+ const MESSAGE_3 = ["Wait?", "What?", "Lo", "How?", "High!"];
+ const MESSAGE_4 = ["??????"];
+ const MESSAGE_5: string[] = ["This one is very long!"];
+ const MESSAGE_6 = ["No", "Caps", "here.", "Right?"];
+
+ // Ensure that none of the arrays were changed mutably
+ // If you fail these, you aren't using map/filter/reduce/etc. properly!
+ afterEach(() => {
+ expect(MESSAGE_1).toEqual(["Hello", "you", "are", "great!"]);
+ expect(MESSAGE_2).toEqual(["oho!", "Oho!", "oHo!", "oHO!", "OHO!"]);
+ expect(MESSAGE_3).toEqual(["Wait?", "What?", "Lo", "How?", "High!"]);
+ expect(MESSAGE_4).toEqual(["??????"]);
+ expect(MESSAGE_5).toEqual(["This one is very long!"]);
+ expect(MESSAGE_6).toEqual(["No", "Caps", "here.", "Right?"]);
+ });
+
+ test("Testing the shoutIfExclaiming function", () => {
+ expect(shoutIfExclaiming(MESSAGE_1)).toEqual([
+ "Hello",
+ "you",
+ "are",
+ "GREAT!"
+ ]);
+ expect(shoutIfExclaiming(MESSAGE_2)).toEqual([
+ "OHO!",
+ "OHO!",
+ "OHO!",
+ "OHO!",
+ "OHO!"
+ ]);
+ expect(shoutIfExclaiming(MESSAGE_3)).toEqual(["Lo", "HIGH!"]);
+ expect(shoutIfExclaiming(MESSAGE_4)).toEqual([]);
+ expect(shoutIfExclaiming(MESSAGE_5)).toEqual([
+ "THIS ONE IS VERY LONG!"
+ ]);
+ expect(shoutIfExclaiming(MESSAGE_6)).toEqual(["No", "Caps", "here."]);
+ });
+
+ //////////////////////////////////
+ // countShortWords
+
+ const WORDS_1 = ["the", "cat", "in", "the", "hat"];
+ const WORDS_2 = ["one", "two", "three", "four", "five", "six", "seven"];
+ const WORDS_3 = ["alpha", "beta", "gamma"];
+ const WORDS_4 = ["Longest", "Words", "Possible"];
+ const WORDS_5: string[] = [];
+ const WORDS_6 = ["", "", "", ""];
+
+ // Ensure that none of the arrays were changed mutably
+ // If you fail these, you aren't using map/filter/reduce/etc. properly!
+ afterEach(() => {
+ expect(WORDS_1).toEqual(["the", "cat", "in", "the", "hat"]);
+ expect(WORDS_2).toEqual([
+ "one",
+ "two",
+ "three",
+ "four",
+ "five",
+ "six",
+ "seven"
+ ]);
+ expect(WORDS_3).toEqual(["alpha", "beta", "gamma"]);
+ expect(WORDS_4).toEqual(["Longest", "Words", "Possible"]);
+ expect(WORDS_5).toEqual([]);
+ expect(WORDS_6).toEqual(["", "", "", ""]);
+ });
+
+ test("Testing the countShortWords function", () => {
+ expect(countShortWords(WORDS_1)).toEqual(5);
+ expect(countShortWords(WORDS_2)).toEqual(3);
+ expect(countShortWords(WORDS_3)).toEqual(0);
+ expect(countShortWords(WORDS_4)).toEqual(0);
+ expect(countShortWords(WORDS_5)).toEqual(0);
+ expect(countShortWords(WORDS_6)).toEqual(4);
+ });
+
+ //////////////////////////////////
+ // allRGB
+
+ const COLORS_1 = ["red", "green", "blue"];
+ const COLORS_2 = ["red", "red", "red"];
+ const COLORS_3 = ["red", "red", "blue", "blue", "green", "red"];
+ const COLORS_4 = ["purple", "orange", "violet"];
+ const COLORS_5 = ["red", "blue", "yellow"];
+ const COLORS_6 = ["green"];
+ const COLORS_7 = ["red"];
+ const COLORS_8 = ["kabluey"];
+ const COLORS_9: string[] = [];
+
+ // Ensure that none of the arrays were changed mutably
+ // If you fail these, you aren't using map/filter/reduce/etc. properly!
+ afterEach(() => {
+ expect(COLORS_1).toEqual(["red", "green", "blue"]);
+ expect(COLORS_2).toEqual(["red", "red", "red"]);
+ expect(COLORS_3).toEqual([
+ "red",
+ "red",
+ "blue",
+ "blue",
+ "green",
+ "red"
+ ]);
+ expect(COLORS_4).toEqual(["purple", "orange", "violet"]);
+ expect(COLORS_5).toEqual(["red", "blue", "yellow"]);
+ expect(COLORS_6).toEqual(["green"]);
+ expect(COLORS_7).toEqual(["red"]);
+ expect(COLORS_8).toEqual(["kabluey"]);
+ expect(COLORS_9).toEqual([]);
+ });
+
+ test("Testing the allRGB function", () => {
+ expect(allRGB(COLORS_1)).toEqual(true);
+ expect(allRGB(COLORS_2)).toEqual(true);
+ expect(allRGB(COLORS_3)).toEqual(true);
+ expect(allRGB(COLORS_4)).toEqual(false);
+ expect(allRGB(COLORS_5)).toEqual(false);
+ expect(allRGB(COLORS_6)).toEqual(true);
+ expect(allRGB(COLORS_7)).toEqual(true);
+ expect(allRGB(COLORS_8)).toEqual(false);
+ expect(allRGB(COLORS_9)).toEqual(true);
+ });
+
+ //////////////////////////////////
+ // makeMath
+
+ test("Testing the makeMath function", () => {
+ expect(makeMath(NUMBERS_1)).toEqual("6=1+2+3");
+ expect(makeMath(NUMBERS_2)).toEqual("600=100+300+200");
+ expect(makeMath(NUMBERS_3)).toEqual("5=5");
+ expect(makeMath(NUMBERS_4)).toEqual("0=0");
+ expect(makeMath(NUMBERS_7)).toEqual("1000=199+1+550+50+200");
+ });
+
+ //////////////////////////////////
+ // injectPositive
+ test("Testing the tripleNumbers function", () => {
+ expect(injectPositive(NUMBERS_1)).toEqual([1, 2, 3, 6]);
+ expect(injectPositive(NUMBERS_2)).toEqual([100, 300, 200, 600]);
+ expect(injectPositive(NUMBERS_3)).toEqual([5, 5]);
+ expect(injectPositive(NUMBERS_4)).toEqual([0]);
+ expect(injectPositive(NUMBERS_5)).toEqual([100, 199, 1, -5, 300, 7, 3]);
+ expect(injectPositive(NUMBERS_6)).toEqual([-100, 0, -200, 100, 200]);
+ expect(injectPositive(NUMBERS_7)).toEqual([199, 1, 550, 50, 200, 1000]);
});
});
From b8777b1873553a2e2780b67fd504486b9d16bd92 Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Tue, 1 Feb 2022 16:09:25 -0500
Subject: [PATCH 27/74] Fix question text
---
src/arrays.ts | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/arrays.ts b/src/arrays.ts
index 7604b40cdb..4a2ffe8e5b 100644
--- a/src/arrays.ts
+++ b/src/arrays.ts
@@ -18,7 +18,7 @@ export function tripleNumbers(numbers: number[]): number[] {
/**
* Consume an array of strings and convert them to integers. If
- * the number cannot be parsed as an integer, convert it to "?" instead.
+ * the number cannot be parsed as an integer, convert it to 0 instead.
*/
export function stringsToIntegers(numbers: string[]): number[] {
return [];
@@ -28,7 +28,7 @@ export function stringsToIntegers(numbers: string[]): number[] {
* Consume an array of strings and return them as numbers. Note that
* the strings MAY have "$" symbols at the beginning, in which case
* those should be removed. If the result cannot be parsed as an integer,
- * convert it to "?" instead.
+ * convert it to 0 instead.
*/
// Remember, you can write functions as lambdas too! They work exactly the same.
export const removeDollars = (amounts: string[]): number[] => {
@@ -37,7 +37,8 @@ export const removeDollars = (amounts: string[]): number[] => {
/**
* Consume an array of messages and return a new list of the messages. However, any
- * string that ends in "!" should be made uppercase.
+ * string that ends in "!" should be made uppercase. Also, remove any strings that end
+ * in question marks ("?").
*/
export const shoutIfExclaiming = (messages: string[]): string[] => {
return [];
@@ -65,6 +66,7 @@ export function allRGB(colors: string[]): boolean {
* numbers being added together along with their actual sum.
*
* For instance, the array [1, 2, 3] would become "6=1+2+3".
+ * And the array [] would become "0=0".
*/
export function makeMath(addends: number[]): string {
return "";
@@ -74,10 +76,10 @@ export function makeMath(addends: number[]): string {
* Consumes an array of numbers and produces a new array of the same numbers,
* with one difference. After the FIRST negative number, insert the sum of all
* previous numbers in the list. If there are no negative numbers, then append
- * 0 to the list.
+ * the sum to the list.
*
* For instance, the array [1, 9, -5, 7] would become [1, 9, -5, 10, 7]
- * And the array [1, 9, 7] would become [1, 9, 0]
+ * And the array [1, 9, 7] would become [1, 9, 7, 17]
*/
export function injectPositive(values: number[]): number[] {
return [];
From f87771e7d8058f6c4fc6d8c6d036953f65b3a775 Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Fri, 11 Feb 2022 14:24:17 -0500
Subject: [PATCH 28/74] Update arrays.test.ts
---
src/arrays.test.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/arrays.test.ts b/src/arrays.test.ts
index 0881d9fe8a..3652078efa 100644
--- a/src/arrays.test.ts
+++ b/src/arrays.test.ts
@@ -261,7 +261,7 @@ describe("Testing the array functions", () => {
//////////////////////////////////
// injectPositive
- test("Testing the tripleNumbers function", () => {
+ test("Testing the injectPositive function", () => {
expect(injectPositive(NUMBERS_1)).toEqual([1, 2, 3, 6]);
expect(injectPositive(NUMBERS_2)).toEqual([100, 300, 200, 600]);
expect(injectPositive(NUMBERS_3)).toEqual([5, 5]);
From f0d316b36ae394d502e75849b5532b76ffdf7c68 Mon Sep 17 00:00:00 2001
From: Austin Cory Bart
Date: Sat, 24 Aug 2024 13:21:13 -0400
Subject: [PATCH 29/74] Add in points
---
src/arrays.test.ts | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/arrays.test.ts b/src/arrays.test.ts
index 3652078efa..c2847517bd 100644
--- a/src/arrays.test.ts
+++ b/src/arrays.test.ts
@@ -7,7 +7,7 @@ import {
removeDollars,
shoutIfExclaiming,
stringsToIntegers,
- tripleNumbers
+ tripleNumbers,
} from "./arrays";
describe("Testing the array functions", () => {
@@ -34,7 +34,7 @@ describe("Testing the array functions", () => {
expect(NUMBERS_7).toEqual([199, 1, 550, 50, 200]);
});
- test("Testing the bookEndList function", () => {
+ test("(3 pts) Testing the bookEndList function", () => {
expect(bookEndList(NUMBERS_1)).toEqual([1, 3]);
expect(bookEndList(NUMBERS_2)).toEqual([100, 200]);
expect(bookEndList(NUMBERS_3)).toEqual([5, 5]);
@@ -43,7 +43,7 @@ describe("Testing the array functions", () => {
expect(bookEndList(NUMBERS_6)).toEqual([-100, 200]);
});
- test("Testing the tripleNumbers function", () => {
+ test("(3 pts) Testing the tripleNumbers function", () => {
expect(tripleNumbers(NUMBERS_1)).toEqual([3, 6, 9]);
expect(tripleNumbers(NUMBERS_2)).toEqual([300, 900, 600]);
expect(tripleNumbers(NUMBERS_3)).toEqual([15]);
@@ -75,7 +75,7 @@ describe("Testing the array functions", () => {
expect(VALUES_7).toEqual(["apple", "banana", "cactus"]);
});
- test("Testing the stringsToIntegers function", () => {
+ test("(3 pts) Testing the stringsToIntegers function", () => {
expect(stringsToIntegers(VALUES_1)).toEqual([1, 2, 3]);
expect(stringsToIntegers(VALUES_2)).toEqual([100, 200, 300]);
expect(stringsToIntegers(VALUES_3)).toEqual([5]);
@@ -110,7 +110,7 @@ describe("Testing the array functions", () => {
expect(AMOUNTS_8).toEqual(["$one", "two", "$three"]);
});
- test("Testing the removeDollars function", () => {
+ test("(3 pts) Testing the removeDollars function", () => {
expect(removeDollars(AMOUNTS_1)).toEqual([1, 2, 3]);
expect(removeDollars(AMOUNTS_2)).toEqual([100, 200, 300, 400]);
expect(removeDollars(AMOUNTS_3)).toEqual([5]);
@@ -142,24 +142,24 @@ describe("Testing the array functions", () => {
expect(MESSAGE_6).toEqual(["No", "Caps", "here.", "Right?"]);
});
- test("Testing the shoutIfExclaiming function", () => {
+ test("(3 pts) Testing the shoutIfExclaiming function", () => {
expect(shoutIfExclaiming(MESSAGE_1)).toEqual([
"Hello",
"you",
"are",
- "GREAT!"
+ "GREAT!",
]);
expect(shoutIfExclaiming(MESSAGE_2)).toEqual([
"OHO!",
"OHO!",
"OHO!",
"OHO!",
- "OHO!"
+ "OHO!",
]);
expect(shoutIfExclaiming(MESSAGE_3)).toEqual(["Lo", "HIGH!"]);
expect(shoutIfExclaiming(MESSAGE_4)).toEqual([]);
expect(shoutIfExclaiming(MESSAGE_5)).toEqual([
- "THIS ONE IS VERY LONG!"
+ "THIS ONE IS VERY LONG!",
]);
expect(shoutIfExclaiming(MESSAGE_6)).toEqual(["No", "Caps", "here."]);
});
@@ -185,7 +185,7 @@ describe("Testing the array functions", () => {
"four",
"five",
"six",
- "seven"
+ "seven",
]);
expect(WORDS_3).toEqual(["alpha", "beta", "gamma"]);
expect(WORDS_4).toEqual(["Longest", "Words", "Possible"]);
@@ -193,7 +193,7 @@ describe("Testing the array functions", () => {
expect(WORDS_6).toEqual(["", "", "", ""]);
});
- test("Testing the countShortWords function", () => {
+ test("(3 pts) Testing the countShortWords function", () => {
expect(countShortWords(WORDS_1)).toEqual(5);
expect(countShortWords(WORDS_2)).toEqual(3);
expect(countShortWords(WORDS_3)).toEqual(0);
@@ -226,7 +226,7 @@ describe("Testing the array functions", () => {
"blue",
"blue",
"green",
- "red"
+ "red",
]);
expect(COLORS_4).toEqual(["purple", "orange", "violet"]);
expect(COLORS_5).toEqual(["red", "blue", "yellow"]);
@@ -236,7 +236,7 @@ describe("Testing the array functions", () => {
expect(COLORS_9).toEqual([]);
});
- test("Testing the allRGB function", () => {
+ test("(3 pts) Testing the allRGB function", () => {
expect(allRGB(COLORS_1)).toEqual(true);
expect(allRGB(COLORS_2)).toEqual(true);
expect(allRGB(COLORS_3)).toEqual(true);
@@ -251,7 +251,7 @@ describe("Testing the array functions", () => {
//////////////////////////////////
// makeMath
- test("Testing the makeMath function", () => {
+ test("(3 pts) Testing the makeMath function", () => {
expect(makeMath(NUMBERS_1)).toEqual("6=1+2+3");
expect(makeMath(NUMBERS_2)).toEqual("600=100+300+200");
expect(makeMath(NUMBERS_3)).toEqual("5=5");
@@ -261,7 +261,7 @@ describe("Testing the array functions", () => {
//////////////////////////////////
// injectPositive
- test("Testing the injectPositive function", () => {
+ test("(3 pts) Testing the injectPositive function", () => {
expect(injectPositive(NUMBERS_1)).toEqual([1, 2, 3, 6]);
expect(injectPositive(NUMBERS_2)).toEqual([100, 300, 200, 600]);
expect(injectPositive(NUMBERS_3)).toEqual([5, 5]);
From 80f1cf6ecfc7e83533d76aa3a68e364f2f0e0614 Mon Sep 17 00:00:00 2001
From: Greg Nelson
Date: Tue, 17 Sep 2024 12:48:04 -0400
Subject: [PATCH 30/74] Update HtmlCss.test.tsx
---
src/HtmlCss.test.tsx | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/HtmlCss.test.tsx b/src/HtmlCss.test.tsx
index 320cb97524..84d76db400 100644
--- a/src/HtmlCss.test.tsx
+++ b/src/HtmlCss.test.tsx
@@ -4,10 +4,10 @@ import App from "./App";
import userEvent from "@testing-library/user-event";
describe("Some HTML Elements are added.", () => {
- test("(2 pts) There is a header", () => {
+ test("(2 pts) There is a heading", () => {
render();
- const header = screen.getByRole("heading");
- expect(header).toBeInTheDocument();
+ const heading = screen.getAllByRole("heading");
+ expect(heading[0]).toBeInTheDocument();
});
test("(2 pts) There is an image with alt text", () => {
From 8a15b188447b2870d838d6fc859fff5b9a20c549 Mon Sep 17 00:00:00 2001
From: nicoumaine <157842474+nicoumaine@users.noreply.github.com>
Date: Tue, 9 Sep 2025 16:03:06 -0400
Subject: [PATCH 31/74] Update App.tsx
---
src/App.tsx | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/App.tsx b/src/App.tsx
index a8b41197f2..5290cf3a29 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -11,6 +11,8 @@ function App(): React.JSX.Element {
Edit src/App.tsx
and save. This page will
automatically reload.
+ Hello World
+
);
}
From ede0e96a8fdb84824eec234d113282fe85445d97 Mon Sep 17 00:00:00 2001
From: nicoumaine <157842474+nicoumaine@users.noreply.github.com>
Date: Tue, 9 Sep 2025 16:05:13 -0400
Subject: [PATCH 32/74] Update App.tsx
---
src/App.tsx | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/App.tsx b/src/App.tsx
index 5290cf3a29..1806eb3fe4 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -9,9 +9,7 @@ function App(): React.JSX.Element {
Edit src/App.tsx
and save. This page will
- automatically reload.
-
- Hello World
+ automatically reload. Hello World
);
From 85065818defaa5092039d2be951aed55aa51ab17 Mon Sep 17 00:00:00 2001
From: nicoumaine <157842474+nicoumaine@users.noreply.github.com>
Date: Tue, 16 Sep 2025 21:34:32 -0400
Subject: [PATCH 33/74] Added "Goofy Goober" header
---
src/App.tsx | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/App.tsx b/src/App.tsx
index 1806eb3fe4..8e9c661f7f 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -4,6 +4,7 @@ import "./App.css";
function App(): React.JSX.Element {
return (