-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix VectorFieldProps, add tests (#33)
* Fix type signature and add tests for VectorField * Add a test for opacity * Add color to the test
- Loading branch information
1 parent
f17797c
commit ffed384
Showing
4 changed files
with
31 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from "react" | ||
import { Theme, VectorField } from ".." | ||
import renderToImage from "../tests/renderToImage" | ||
|
||
describe("<VectorField />", () => { | ||
it("Renders", async () => { | ||
const a = { x: 5.1, y: 5.1 } | ||
expect( | ||
await renderToImage( | ||
<VectorField xy={(x, y) => [y - a.y - (x - a.x), -(x - a.x) - (y - a.y)]} step={0.5} /> | ||
) | ||
).toMatchImageSnapshot() | ||
}) | ||
|
||
it("Supports opacity functions", async () => { | ||
expect( | ||
await renderToImage( | ||
<VectorField | ||
xy={() => [0.5, 0.5]} | ||
step={1} | ||
xyOpacity={(x, y) => Math.min(Math.sqrt(x ** 2 + y ** 2) / 10, 1)} | ||
color={Theme.red} | ||
/> | ||
) | ||
).toMatchImageSnapshot() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+111 KB
...splay/__image_snapshots__/vector-field-test-tsx-vector-field-renders-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+28 KB
...hots__/vector-field-test-tsx-vector-field-supports-opacity-functions-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.