Skip to content

Commit d82c732

Browse files
committed
add simple unit tests
1 parent bd3e5c3 commit d82c732

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

testing/blobs.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import blobs, {BlobOptions} from "..";
2+
3+
describe("blobs", () => {
4+
it("should return a different result when seed is not provided", () => {
5+
const options: BlobOptions = {size: 100, complexity: 1, contrast: 1, color: "red"};
6+
7+
const a = blobs(options);
8+
const b = blobs(options);
9+
10+
expect(a).not.toEqual(b);
11+
});
12+
13+
it("should return the same result when the seed is provided", () => {
14+
const options: BlobOptions = {size: 200, complexity: 0.5, contrast: 0.5, color: "blue"};
15+
options.seed = "abcde";
16+
17+
const a = blobs(options);
18+
const b = blobs(options);
19+
20+
expect(a).toEqual(b);
21+
});
22+
});

testing/snapshots.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import blobs, {BlobOptions} from "..";
33
// Sanity checks to ensure the output remains consistent
44
// across changes to the source.
55
const testCases: Record<string, BlobOptions> = {
6-
"fill": {
6+
fill: {
77
size: 109,
88
complexity: 0.1,
99
contrast: 0.331,
1010
color: "red",
1111
seed: "fill",
1212
},
13-
"stroke": {
13+
stroke: {
1414
size: 226,
1515
complexity: 0.91,
1616
contrast: 0.6,
@@ -20,15 +20,14 @@ const testCases: Record<string, BlobOptions> = {
2020
},
2121
seed: "stroke",
2222
},
23-
"guides": {
23+
guides: {
2424
size: 781,
2525
complexity: 1,
2626
contrast: 0.331,
2727
color: "yellow",
2828
guides: true,
2929
seed: "guides",
3030
},
31-
3231
};
3332

3433
for (const testCase of Object.keys(testCases)) {

0 commit comments

Comments
 (0)