Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using flat confetti for scale tests, for better consistency #218

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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