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

feat(number-field): support long press at spinner #992

Merged
merged 8 commits into from
Oct 20, 2023
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '@refinitiv-ui/elements/number-field';

import '@refinitiv-ui/elemental-theme/light/ef-number-field';
import { elementUpdated, expect, fixture } from '@refinitiv-ui/test-helpers';
import { aTimeout, elementUpdated, expect, fixture, oneEvent } from '@refinitiv-ui/test-helpers';

const UP = 1;
const DOWN = -1;
Expand Down Expand Up @@ -220,4 +220,39 @@ describe('number-field/Step', function () {
await expectValues(el, [-1, -2, -3, -4, -5], UP, -1.5);
});
});

describe('Long press spinner', function () {
const dispatchLongTapEvent = async (el, wait = 1000) => {
setTimeout(() =>
el.dispatchEvent(
new Event('tapstart', {
bubbles: true
})
)
);
await oneEvent(el, 'tapstart');
if (wait) {
await aTimeout(wait);
}
setTimeout(() =>
el.dispatchEvent(
new Event('tapend', {
bubbles: true
})
)
);
await oneEvent(el, 'tapend');
};

it('Should increases value gradually on long press', async function () {
const el = await fixture('<ef-number-field></ef-number-field>');
await dispatchLongTapEvent(el.spinnerUpEl);
expect(Number(el.value)).to.greaterThan(1);
});
it('Should decreases value gradually on long press', async function () {
const el = await fixture('<ef-number-field></ef-number-field>');
await dispatchLongTapEvent(el.spinnerDownEl);
expect(Number(el.value)).to.lessThan(-1);
});
});
});
Loading
Loading