Skip to content

Commit

Permalink
Merge pull request #218 from catdad/cleanup-scale-tests
Browse files Browse the repository at this point in the history
using flat confetti for scale tests, for better consistency
  • Loading branch information
catdad authored Dec 5, 2023
2 parents b7ec1c1 + f841fa9 commit 4c1c86d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,17 @@ test('shoots default scaled confetti', async t => {
t.context.buffer = await confettiImage(page, {
colors: ['#0000ff'],
shapes: ['circle'],
particleCount: 10
particleCount: 1,
startVelocity: 0,
gravity: 0,
flat: true
});
t.context.image = await removeOpacity(t.context.buffer);

const pixels = await totalPixels(t.context.image);

t.is(pixels > 100 && pixels < 500, true);
const expected = 124;
t.true(pixels > expected * .99 && pixels < expected * 1.01, `${pixels}±1% ≠ ${expected}`);
});

test('shoots larger scaled confetti', async t => {
Expand All @@ -393,13 +397,17 @@ test('shoots larger scaled confetti', async t => {
colors: ['#0000ff'],
shapes: ['circle'],
scalar: 10,
particleCount: 10
particleCount: 1,
startVelocity: 0,
gravity: 0,
flat: true
});
t.context.image = await removeOpacity(t.context.buffer);

const pixels = await totalPixels(t.context.image);

t.is(pixels > 2000, true);
const expected = 11476;
t.true(pixels > expected * .99 && pixels < expected * 1.01, `${pixels} ± 1% ≠ ${expected}`);
});

test('shoots confetti to the left', async t => {
Expand Down

0 comments on commit 4c1c86d

Please sign in to comment.