From a2b3e71b47f6430010f1b69315a89f045a2bb860 Mon Sep 17 00:00:00 2001 From: Rachel Leggett Date: Sat, 29 May 2021 22:01:27 -0400 Subject: [PATCH 1/3] delete starter test --- src/App.test.js | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 src/App.test.js diff --git a/src/App.test.js b/src/App.test.js deleted file mode 100644 index 4db7ebc..0000000 --- a/src/App.test.js +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react'; -import { render } from '@testing-library/react'; -import App from './App'; - -test('renders learn react link', () => { - const { getByText } = render(); - const linkElement = getByText(/learn react/i); - expect(linkElement).toBeInTheDocument(); -}); From b6a28d94ee9bb5f53ac4b07de6456bd44ec3744b Mon Sep 17 00:00:00 2001 From: Rachel Leggett Date: Sat, 29 May 2021 23:51:42 -0400 Subject: [PATCH 2/3] a few tests, a few tiny updates, prettier on a few files --- src/HatComponents/HatAbbrevs.js | 36 +++++----- src/HatComponents/HatAbbrevs.test.js | 8 +++ src/HeaderImage.js | 18 +++-- src/HeaderImage.test.js | 8 +++ src/SockComponents/CuffDownCuff.js | 30 +++++--- src/SockComponents/ShortRowHeel.js | 64 ++++++++++++------ src/SockComponents/SockAbbrevs.js | 94 +++++++++++++++----------- src/SockComponents/SockAbbrevs.test.js | 28 ++++++++ 8 files changed, 187 insertions(+), 99 deletions(-) create mode 100644 src/HatComponents/HatAbbrevs.test.js create mode 100644 src/HeaderImage.test.js create mode 100644 src/SockComponents/SockAbbrevs.test.js diff --git a/src/HatComponents/HatAbbrevs.js b/src/HatComponents/HatAbbrevs.js index 059b293..37c06ac 100644 --- a/src/HatComponents/HatAbbrevs.js +++ b/src/HatComponents/HatAbbrevs.js @@ -1,21 +1,21 @@ -import React from 'react'; +import React from "react"; -function HatAbbrevs(props) { - return ( -
-

Abbreviations

-

- CO = cast on
- rep = repeat
- Rnd = round
- k = knit
- p = purl
- k2tog = knit two together
- st(s) = stitch(es)
- Stockinette stitch = knit all stitches -

-
- ); +function HatAbbrevs() { + return ( +
+

Abbreviations

+
    +
  • CO = cast on
  • +
  • rep = repeat
  • +
  • Rnd = round
  • +
  • k = knit
  • +
  • p = purl
  • +
  • k2tog = knit two together
  • +
  • st(s) = stitch(es)
  • +
  • Stockinette stitch = knit all stitches
  • +
+
+ ); } -export default HatAbbrevs; \ No newline at end of file +export default HatAbbrevs; diff --git a/src/HatComponents/HatAbbrevs.test.js b/src/HatComponents/HatAbbrevs.test.js new file mode 100644 index 0000000..74bc7a5 --- /dev/null +++ b/src/HatComponents/HatAbbrevs.test.js @@ -0,0 +1,8 @@ +import React from "react"; +import { render, screen } from "@testing-library/react"; +import HatAbbrevs from "./HatAbbrevs"; + +test("", () => { + render(); + expect(screen.queryByRole("list")).toBeTruthy(); +}); diff --git a/src/HeaderImage.js b/src/HeaderImage.js index f384460..fd3fee2 100644 --- a/src/HeaderImage.js +++ b/src/HeaderImage.js @@ -1,13 +1,11 @@ -import React from 'react' +import React from "react"; -function HeaderImage(props) { - return ( -
- {props.alt} -
- ) +function HeaderImage({ colClass, url, alt }) { + return ( +
+ {alt} +
+ ); } -export default HeaderImage \ No newline at end of file +export default HeaderImage; diff --git a/src/HeaderImage.test.js b/src/HeaderImage.test.js new file mode 100644 index 0000000..89bc19f --- /dev/null +++ b/src/HeaderImage.test.js @@ -0,0 +1,8 @@ +import React from "react"; +import { render, screen } from "@testing-library/react"; +import HeaderImage from "./HeaderImage"; + +test("HeaderImage renders an image with alt text", () => { + render(); + expect(screen.getByRole("img")).toHaveAttribute("alt", "test"); +}); diff --git a/src/SockComponents/CuffDownCuff.js b/src/SockComponents/CuffDownCuff.js index 8520d92..b140252 100644 --- a/src/SockComponents/CuffDownCuff.js +++ b/src/SockComponents/CuffDownCuff.js @@ -1,15 +1,23 @@ -import React from 'react'; +import React from "react"; function CuffDownCuff(props) { - return ( -
-

Cuff and Leg

-

Cast on {props.state.fullStCount} sts loosely or with a stretchy cast-on. Join to work in the rnd, being careful not to twist.

-

Rnd 1: *k2, p2; rep from * to end
- Rep rnd 1 until ribbing measures one inch, or until desired length.

-

Knit every rnd until work measures 6 inches, or until desired length.

-
- ) + return ( +
+

Cuff and Leg

+

+ Cast on {props.state.fullStCount} sts loosely or with a stretchy + cast-on. Join to work in the rnd, being careful not to twist. +

+

+ Rnd 1: *k2, p2; rep from * to end +
+ Rep rnd 1 until ribbing measures one inch, or until desired length. +

+

+ Knit every rnd until work measures 6 inches, or until desired length. +

+
+ ); } -export default CuffDownCuff; \ No newline at end of file +export default CuffDownCuff; diff --git a/src/SockComponents/ShortRowHeel.js b/src/SockComponents/ShortRowHeel.js index 9ac5283..8c7c1f2 100644 --- a/src/SockComponents/ShortRowHeel.js +++ b/src/SockComponents/ShortRowHeel.js @@ -1,26 +1,52 @@ -import React from 'react'; +import React from "react"; function ShortRowHeel(props) { - return ( -
-

Heel

-

The short row heel is worked flat over the next {props.state.fullStCount / 2} sts, which are half your total sts. References to the first and last sts in these instructions refer to the first of this half and the last of this half of your sts, i.e. the heel sts.

+ return ( +
+

Heel

+

+ The short row heel is worked flat over the next{" "} + {props.state.fullStCount / 2} sts, which are half your total sts. + References to the first and last sts in these instructions refer to the + first of this half and the last of this half of your sts, i.e. the heel + sts. +

-

First half of the heel

-

Row 1 (RS): k across to last st, w&t
- Row 2 (WS): p back to first st, w&t
- Row 3 (RS): k to st before wrapped st, w&t
- Row 4 (WS): p to st before wrapped st, w&t

+

First half of the heel

+

+ Row 1 (RS): k across to last st, w&t +
+ Row 2 (WS): p back to first st, w&t +
+ Row 3 (RS): k to st before wrapped st, w&t +
+ Row 4 (WS): p to st before wrapped st, w&t +

-

Rep rows 3 and 4 until {props.getMultiple((props.state.fullStCount / 6), 2)} sts are left unwrapped, ending after a WS row.

+

+ Rep rows 3 and 4 until{" "} + {props.getMultiple(props.state.fullStCount / 6, 2)} sts are left + unwrapped, ending after a WS row. +

-

Second half of the heel

-

Row 1 (RS): k to first wrapped st, k the wrapped st while picking up the wrap, turn
- Row 2 (WS): sl1 wyif, p to first/next wrapped st, p the wrapped st while picking up the wrap, turn
- Row 3 (RS): sl1 wyib, k to next wrapped st, k the wrapped st while picking up the wrap, turn

-

Rep rows 2 and 3 until all wraps have been picked up, ending with a RS row. You are now ready to continue in the rnd to work the rest of the sock.

-
- ); +

Second half of the heel

+

+ Row 1 (RS): k to first wrapped st, k the wrapped st while picking up the + wrap, turn +
+ Row 2 (WS): sl1 wyif, p to first/next wrapped st, p the wrapped st while + picking up the wrap, turn +
+ Row 3 (RS): sl1 wyib, k to next wrapped st, k the wrapped st while + picking up the wrap, turn +

+

+ Rep rows 2 and 3 until all wraps have been picked up, ending with a RS + row. You are now ready to continue in the rnd to work the rest of the + sock. +

+
+ ); } -export default ShortRowHeel; \ No newline at end of file +export default ShortRowHeel; diff --git a/src/SockComponents/SockAbbrevs.js b/src/SockComponents/SockAbbrevs.js index 075a1be..9e122b9 100644 --- a/src/SockComponents/SockAbbrevs.js +++ b/src/SockComponents/SockAbbrevs.js @@ -1,44 +1,56 @@ -import React from 'react'; +import React from "react"; -function SockAbbrevs(props) { - return ( -
-

These instructions are written for the magic loop or two circular needles methods, - as they reference the first needle and second needle. To adapt for dpns, - the first needle is dpn one and two and the second needle is dpn three and four.

-

Abbreviations

-

- BOR = beginning of round
- k = knit
- {props.direction === 'toeup' && - - kfb = k in front and back of same st
-
- } - p = purl
- {props.heeltype === 'flap' && p2tog = p two together
} - Rep = repeat
- Rnd(s) = round(s)
- RS = right side
- sl = slip (purlwise unless otherwise specified)
- {props.direction === 'cuffdown' && - - ssk = - slip, slip, knit (left-leaning decrease) -
-
- } - st(s) = stitch(es)
- WS = wrong side
- {props.heeltype === 'shortrow' && - w&t = wrap and turn
} - wyib = with yarn in back
- wyif = with yarn in front -

-
- ); +function SockAbbrevs({ direction, heeltype }) { + return ( +
+

+ These instructions are written for the magic loop or two circular + needles methods, as they reference the first needle and second needle. + To adapt for dpns, the first needle is dpn one and two and the second + needle is dpn three and four. +

+

Abbreviations

+
    +
  • BOR = beginning of round
  • +
  • k = knit
  • + {direction === "toeup" &&
  • kfb = k in front and back of same st
  • } +
  • p = purl
  • + {heeltype === "flap" &&
  • p2tog = p two together
  • } +
  • Rep = repeat
  • +
  • Rnd(s) = round(s)
  • +
  • RS = right side
  • +
  • sl = slip (purlwise unless otherwise specified)
  • + {direction === "cuffdown" && ( +
  • + ssk ={" "} + + slip, slip, knit (left-leaning decrease) + +
  • + )} +
  • st(s) = stitch(es)
  • +
  • WS = wrong side
  • + {heeltype === "shortrow" && ( +
  • + w&t ={" "} + + wrap and turn + +
  • + )} +
  • wyib = with yarn in back
  • +
  • wyif = with yarn in front
  • +
+
+ ); } -export default SockAbbrevs; \ No newline at end of file +export default SockAbbrevs; diff --git a/src/SockComponents/SockAbbrevs.test.js b/src/SockComponents/SockAbbrevs.test.js new file mode 100644 index 0000000..0e5577c --- /dev/null +++ b/src/SockComponents/SockAbbrevs.test.js @@ -0,0 +1,28 @@ +import React from "react"; +import { cleanup, render, screen } from "@testing-library/react"; +import SockAbbrevs from "./SockAbbrevs"; + +test("SockAbbrevs should contain a list", () => { + render(); + expect(screen.queryByRole("list")).toBeTruthy(); +}); + +test("List should show correct items for direction prop", () => { + render(); + expect( + screen.getByText("kfb = k in front and back of same st") + ).toBeVisible(); + expect( + screen.queryByText("slip, slip, knit (left-leaning decrease)") + ).toBeFalsy(); + + cleanup(); + + render(); + expect( + screen.queryByText("kfb = k in front and back of same st") + ).toBeFalsy(); + expect( + screen.getByText("slip, slip, knit (left-leaning decrease)") + ).toBeVisible(); +}); From e14952bc477d5f49f015e24235059cfab2fa29a1 Mon Sep 17 00:00:00 2001 From: Rachel Leggett Date: Sun, 30 May 2021 13:06:35 -0400 Subject: [PATCH 3/3] some tests and fixed the toe up mult of 4 bug --- src/SockComponents/CuffDownToe.js | 54 ++++++++++++++----- src/SockComponents/SockAbbrevs.test.js | 28 ---------- src/SockComponents/ToeUpPattern.js | 28 +++++----- src/SockComponents/ToeUpToe.js | 49 ++++++++++++----- src/{ => tests}/HeaderImage.test.js | 2 +- src/tests/SockAbbrevs.test.js | 10 ++++ src/tests/SockRecipeToeUp.test.js | 10 ++++ src/tests/ToeUpToe.test.js | 30 +++++++++++ src/tests/__snapshots__/ToeUpToe.test.js.snap | 48 +++++++++++++++++ 9 files changed, 190 insertions(+), 69 deletions(-) delete mode 100644 src/SockComponents/SockAbbrevs.test.js rename src/{ => tests}/HeaderImage.test.js (85%) create mode 100644 src/tests/SockAbbrevs.test.js create mode 100644 src/tests/SockRecipeToeUp.test.js create mode 100644 src/tests/ToeUpToe.test.js create mode 100644 src/tests/__snapshots__/ToeUpToe.test.js.snap diff --git a/src/SockComponents/CuffDownToe.js b/src/SockComponents/CuffDownToe.js index a5ca562..b56607d 100644 --- a/src/SockComponents/CuffDownToe.js +++ b/src/SockComponents/CuffDownToe.js @@ -1,18 +1,44 @@ -import React from 'react'; +import React from "react"; function CuffDownToe(props) { - return( -
-

Toe

-

Knit to the beginning of the instep sts, then begin the toe decreases as follows:

-

Rnd 1, instep/needle 1: k1, ssk, k to last 3 sts of instep, k2tog, k1
- Rnd 1, sole/needle 2: k1, ssk, k to last 3 sts of sole, k2tog, k1
- Rnd 2: k around

-

Rep rnds 1 and 2 until you have {props.state.fullStCount / 2} sts remaining. Then, rep rnd 1 twice more.

-

At the end of your decreases, you should have { (props.state.fullStCount / 2) - 8 } sts remaining, { props.getMultiple((((props.state.fullStCount / 2) - 8) / 2), 2) } on the instep and { props.getMultiple((((props.state.fullStCount / 2) - 8) / 2), 2) } on the sole.

-

Cut the yarn, leaving a tail long enough to graft the toe. Use the Kitchener stitch to graft the toe closed.

-
- ); + return ( +
+

Toe

+

+ Knit to the beginning of the instep sts, then begin the toe decreases as + follows: +

+

+ Rnd 1, instep/needle 1: k1, ssk, k to last 3 sts of instep, k2tog, k1 +
+ Rnd 1, sole/needle 2: k1, ssk, k to last 3 sts of sole, k2tog, k1 +
+ Rnd 2: k around +

+

+ Rep rnds 1 and 2 until you have {props.state.fullStCount / 2} sts + remaining. Then, rep rnd 1 twice more. +

+

+ At the end of your decreases, you should have{" "} + {props.state.fullStCount / 2 - 8} sts remaining,{" "} + {props.getMultiple((props.state.fullStCount / 2 - 8) / 2, 2)} on the + instep and {props.getMultiple((props.state.fullStCount / 2 - 8) / 2, 2)}{" "} + on the sole. +

+

+ Cut the yarn, leaving a tail long enough to graft the toe. Use the{" "} + + Kitchener stitch + {" "} + to graft the toe closed. +

+
+ ); } -export default CuffDownToe; \ No newline at end of file +export default CuffDownToe; diff --git a/src/SockComponents/SockAbbrevs.test.js b/src/SockComponents/SockAbbrevs.test.js deleted file mode 100644 index 0e5577c..0000000 --- a/src/SockComponents/SockAbbrevs.test.js +++ /dev/null @@ -1,28 +0,0 @@ -import React from "react"; -import { cleanup, render, screen } from "@testing-library/react"; -import SockAbbrevs from "./SockAbbrevs"; - -test("SockAbbrevs should contain a list", () => { - render(); - expect(screen.queryByRole("list")).toBeTruthy(); -}); - -test("List should show correct items for direction prop", () => { - render(); - expect( - screen.getByText("kfb = k in front and back of same st") - ).toBeVisible(); - expect( - screen.queryByText("slip, slip, knit (left-leaning decrease)") - ).toBeFalsy(); - - cleanup(); - - render(); - expect( - screen.queryByText("kfb = k in front and back of same st") - ).toBeFalsy(); - expect( - screen.getByText("slip, slip, knit (left-leaning decrease)") - ).toBeVisible(); -}); diff --git a/src/SockComponents/ToeUpPattern.js b/src/SockComponents/ToeUpPattern.js index 5267022..e16b29d 100644 --- a/src/SockComponents/ToeUpPattern.js +++ b/src/SockComponents/ToeUpPattern.js @@ -1,18 +1,18 @@ -import React from 'react'; -import ToeUpToe from './ToeUpToe'; -import Foot from './Foot'; -import ShortRowHeel from './ShortRowHeel'; -import ToeUpCuff from './ToeUpCuff'; +import React from "react"; +import ToeUpToe from "./ToeUpToe"; +import Foot from "./Foot"; +import ShortRowHeel from "./ShortRowHeel"; +import ToeUpCuff from "./ToeUpCuff"; function ToeUpPattern(props) { - return( -
- - - - -
- ) + return ( +
+ + + + +
+ ); } -export default ToeUpPattern; \ No newline at end of file +export default ToeUpPattern; diff --git a/src/SockComponents/ToeUpToe.js b/src/SockComponents/ToeUpToe.js index 6b92f8d..fcdcebb 100644 --- a/src/SockComponents/ToeUpToe.js +++ b/src/SockComponents/ToeUpToe.js @@ -1,15 +1,40 @@ -import React from 'react'; +import React from "react"; -function ToeUpToe(props) { - return( -
-

Toe

-

Using Judy's Magic Cast On, cast on {(props.state.fullStCount / 2) - 8} sts.

-

Rnd 1: kfb, k to 2 sts before end of first needle, kfb, k1, kfb, k to 2 sts before end of second needle, kfb, k1
- Rnd 2: k around

-

Rep rnds 1 and 2 until you have {props.state.fullStCount} sts. For a slightly more rounded toe, try repeating the first rnd twice before starting to repeat both rnds.

-
- ) +function ToeUpToe({ fullStCount }) { + return ( +
+

Toe

+

+ Using{" "} + + Judy's Magic Cast On + + , cast on{" "} + + {fullStCount / 2 - 8 - ((fullStCount / 2 - 8) % 4)} + {" "} + sts. +

+

+ Rnd 1: kfb, k to 2 sts before end of first needle, kfb, k1, kfb, k to 2 + sts before end of second needle, kfb, k1 +
+ Rnd 2: k around +

+

+ Rep rnds 1 and 2 until you have{" "} + {fullStCount} sts.{" "} + + For a slightly more rounded toe, try repeating the first rnd twice + before starting to repeat both rnds. + +

+
+ ); } -export default ToeUpToe; \ No newline at end of file +export default ToeUpToe; diff --git a/src/HeaderImage.test.js b/src/tests/HeaderImage.test.js similarity index 85% rename from src/HeaderImage.test.js rename to src/tests/HeaderImage.test.js index 89bc19f..2bf70d9 100644 --- a/src/HeaderImage.test.js +++ b/src/tests/HeaderImage.test.js @@ -1,6 +1,6 @@ import React from "react"; import { render, screen } from "@testing-library/react"; -import HeaderImage from "./HeaderImage"; +import HeaderImage from "../HeaderImage"; test("HeaderImage renders an image with alt text", () => { render(); diff --git a/src/tests/SockAbbrevs.test.js b/src/tests/SockAbbrevs.test.js new file mode 100644 index 0000000..d457b19 --- /dev/null +++ b/src/tests/SockAbbrevs.test.js @@ -0,0 +1,10 @@ +import React from "react"; +import { cleanup, render, screen } from "@testing-library/react"; +import SockAbbrevs from "../SockComponents/SockAbbrevs"; + +afterEach(cleanup); + +test("SockAbbrevs should contain a list", () => { + render(); + expect(screen.queryByRole("list")).toBeTruthy(); +}); diff --git a/src/tests/SockRecipeToeUp.test.js b/src/tests/SockRecipeToeUp.test.js new file mode 100644 index 0000000..ca6ff6a --- /dev/null +++ b/src/tests/SockRecipeToeUp.test.js @@ -0,0 +1,10 @@ +import React from "react"; +import { render } from "@testing-library/react"; +import Recipe from "../SockComponents/Recipe"; + +test("Toe up recipe should render with short row heel", () => { + /* const { container } = render( + + ); + expect(container.firstChild).toMatchSnapshot(); */ +}); diff --git a/src/tests/ToeUpToe.test.js b/src/tests/ToeUpToe.test.js new file mode 100644 index 0000000..59a7b13 --- /dev/null +++ b/src/tests/ToeUpToe.test.js @@ -0,0 +1,30 @@ +import React from "react"; +import { render, screen, cleanup } from "@testing-library/react"; +import ToeUpToe from "../SockComponents/ToeUpToe"; + +afterEach(cleanup); + +test("Toe up toe should render correctly", () => { + const { container } = render(); + expect(container.firstChild).toMatchSnapshot(); +}); + +test("Difference between toe up starting st count and final st count should be a multiple of 4", () => { + render(); + let startingStCount = Number( + screen.getByTestId("toeup-startingStCount").textContent + ); + let fullStCount = Number( + screen.getByTestId("toeup-finalStCount").textContent + ); + expect((fullStCount - startingStCount) % 4).toBe(0); + cleanup(); + + render(); + startingStCount = Number( + screen.getByTestId("toeup-startingStCount").textContent + ); + fullStCount = Number(screen.getByTestId("toeup-finalStCount").textContent); + expect((fullStCount - startingStCount) % 4).toBe(0); + cleanup(); +}); diff --git a/src/tests/__snapshots__/ToeUpToe.test.js.snap b/src/tests/__snapshots__/ToeUpToe.test.js.snap new file mode 100644 index 0000000..202dddb --- /dev/null +++ b/src/tests/__snapshots__/ToeUpToe.test.js.snap @@ -0,0 +1,48 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Toe up toe should render correctly 1`] = ` +
+

+ Toe +

+

+ Using + + + Judy's Magic Cast On + + , cast on + + + 20 + + + sts. +

+

+ Rnd 1: kfb, k to 2 sts before end of first needle, kfb, k1, kfb, k to 2 sts before end of second needle, kfb, k1 +
+ Rnd 2: k around +

+

+ Rep rnds 1 and 2 until you have + + + 60 + + sts. + + + For a slightly more rounded toe, try repeating the first rnd twice before starting to repeat both rnds. + +

+
+`;