Skip to content

Commit

Permalink
Add tests for ParametricFunction (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenpetryk authored Sep 8, 2021
1 parent c6d3187 commit f17797c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/display/FunctionGraph.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react"
import FunctionGraph from "./FunctionGraph"
import { FunctionGraph, Theme } from ".."
import renderToImage from "../tests/renderToImage"

describe("<FunctionGraph.OfX />", () => {
Expand All @@ -22,10 +22,24 @@ describe("<FunctionGraph.Parametric />", () => {
expect(
await renderToImage(
<>
{/* Good defaults test */}
<FunctionGraph.Parametric
t={[0, 4 * Math.PI]}
xy={(t) => [3 + t * Math.cos(t), 3 + t * Math.sin(t)]}
xy={(t) => [7 + (t * Math.cos(t)) / 5, 3 + (t * Math.sin(t)) / 5]}
/>

{/* Styles and sample rate */}
<FunctionGraph.Parametric
t={[0, 2 * Math.PI]}
xy={(t) => [3 - (t * Math.cos(t)) / 3, 6 - (t * Math.sin(t)) / 3]}
style="dashed"
color={Theme.blue}
weight={5}
samples={10}
/>

{/* When `t` is a backwards range (higher to lower) */}
<FunctionGraph.Parametric t={[5, 0]} xy={(t) => [t, 2 + Math.sin(t)]} color={Theme.red} />
</>
)
).toMatchImageSnapshot()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f17797c

Please sign in to comment.