Skip to content

Commit

Permalink
feat(number-field): support long press at spinner (#983)
Browse files Browse the repository at this point in the history
  • Loading branch information
Theeraphat-Sorasetsakul authored Oct 20, 2023
1 parent b656521 commit 606660d
Show file tree
Hide file tree
Showing 3 changed files with 241 additions and 163 deletions.
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

0 comments on commit 606660d

Please sign in to comment.