Skip to content

Commit 03142d8

Browse files
committed
use act properly
1 parent 121a9b9 commit 03142d8

File tree

1 file changed

+40
-40
lines changed
  • packages/form-js-viewer/test/spec/render/components/form-fields

1 file changed

+40
-40
lines changed

packages/form-js-viewer/test/spec/render/components/form-fields/Select.spec.js

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ describe('Select', function() {
306306

307307
describe('interaction (static data)', function() {
308308

309-
it('should set value through dropdown', function() {
309+
it('should set value through dropdown', async function() {
310310

311311
// given
312312
const onChangeSpy = spy();
@@ -319,10 +319,10 @@ describe('Select', function() {
319319
const select = container.querySelector('.fjs-input-group');
320320

321321
// when
322-
fireEvent.focus(select);
322+
await act(() => fireEvent.focus(select));
323323

324324
const germanSelector = container.querySelector('.fjs-dropdownlist .fjs-dropdownlist-item');
325-
fireEvent.mouseDown(germanSelector);
325+
await act(() => fireEvent.mouseDown(germanSelector));
326326

327327
// then
328328
expect(onChangeSpy).to.have.been.calledWith({
@@ -332,7 +332,7 @@ describe('Select', function() {
332332
});
333333

334334

335-
it('should clear', function() {
335+
it('should clear', async function() {
336336

337337
// given
338338
const onChangeSpy = spy();
@@ -344,7 +344,7 @@ describe('Select', function() {
344344

345345
// when
346346
const cross = container.querySelector('.fjs-select-cross');
347-
fireEvent.mouseDown(cross);
347+
await act(() => fireEvent.mouseDown(cross));
348348

349349
// then
350350
const dropdown = container.querySelector('.fjs-dropdownlist');
@@ -360,7 +360,7 @@ describe('Select', function() {
360360

361361
describe('interaction (dynamic data, valuesKey)', function() {
362362

363-
it('should set value through dropdown', function() {
363+
it('should set value through dropdown', async function() {
364364

365365
// given
366366
const onChangeSpy = spy();
@@ -375,11 +375,11 @@ describe('Select', function() {
375375
const select = container.querySelector('.fjs-input-group');
376376

377377
// when
378-
fireEvent.focus(select);
378+
await act(() => fireEvent.focus(select));
379379

380380
const germanSelector = container.querySelector('.fjs-dropdownlist .fjs-dropdownlist-item');
381381

382-
fireEvent.mouseDown(germanSelector);
382+
await act(() => fireEvent.mouseDown(germanSelector));
383383

384384
// then
385385
expect(onChangeSpy).to.have.been.calledWith({
@@ -389,7 +389,7 @@ describe('Select', function() {
389389
});
390390

391391

392-
it('should clear', function() {
392+
it('should clear', async function() {
393393

394394
// given
395395
const onChangeSpy = spy();
@@ -403,7 +403,7 @@ describe('Select', function() {
403403

404404
// when
405405
const cross = container.querySelector('.fjs-select-cross');
406-
fireEvent.mouseDown(cross);
406+
await act(() => fireEvent.mouseDown(cross));
407407

408408
// then
409409
expect(onChangeSpy).to.have.been.calledWith({
@@ -418,7 +418,7 @@ describe('Select', function() {
418418

419419
describe('interaction (dynamic data, valuesExpression)', function() {
420420

421-
it('should set value through dropdown', function() {
421+
it('should set value through dropdown', async function() {
422422

423423
// given
424424
const onChangeSpy = spy();
@@ -444,11 +444,11 @@ describe('Select', function() {
444444
const select = container.querySelector('.fjs-input-group');
445445

446446
// when
447-
fireEvent.focus(select);
447+
await act(() => fireEvent.focus(select));
448448

449449
const germanSelector = container.querySelector('.fjs-dropdownlist .fjs-dropdownlist-item');
450450

451-
fireEvent.mouseDown(germanSelector);
451+
await act(() => fireEvent.mouseDown(germanSelector));
452452

453453
// then
454454
expect(onChangeSpy).to.have.been.calledWith({
@@ -458,7 +458,7 @@ describe('Select', function() {
458458
});
459459

460460

461-
it('should render options from values expression', function() {
461+
it('should render options from values expression', async function() {
462462

463463
// given
464464
const onChangeSpy = spy();
@@ -484,7 +484,7 @@ describe('Select', function() {
484484
const select = container.querySelector('.fjs-input-group');
485485

486486
// when
487-
fireEvent.focus(select);
487+
await act(() => fireEvent.focus(select));
488488

489489
// then
490490
expect(getSelectValues(container)).to.eql([
@@ -496,7 +496,7 @@ describe('Select', function() {
496496
});
497497

498498

499-
it('should update options when evaluation changed', function() {
499+
it('should update options when evaluation changed', async function() {
500500

501501
// given
502502
const onChangeSpy = spy();
@@ -522,7 +522,7 @@ describe('Select', function() {
522522
const select = result.container.querySelector('.fjs-input-group');
523523

524524
// when
525-
fireEvent.focus(select);
525+
await act(() => fireEvent.focus(select));
526526

527527
// assume
528528
expect(getSelectValues(result.container)).to.eql([
@@ -557,7 +557,7 @@ describe('Select', function() {
557557
});
558558

559559

560-
it('should update options - roundtrip', function() {
560+
it('should update options - roundtrip', async function() {
561561

562562
// given
563563
const onChangeSpy = spy();
@@ -583,7 +583,7 @@ describe('Select', function() {
583583
const select = result.container.querySelector('.fjs-input-group');
584584

585585
// when
586-
fireEvent.focus(select);
586+
await act(() => fireEvent.focus(select));
587587

588588
// assume
589589
expect(getSelectValues(result.container)).to.eql([
@@ -651,7 +651,7 @@ describe('Select', function() {
651651
});
652652

653653

654-
it('should clear', function() {
654+
it('should clear', async function() {
655655

656656
// given
657657
const onChangeSpy = spy();
@@ -676,7 +676,7 @@ describe('Select', function() {
676676

677677
// when
678678
const cross = container.querySelector('.fjs-select-cross');
679-
fireEvent.mouseDown(cross);
679+
await act(() => fireEvent.mouseDown(cross));
680680

681681
// then
682682
expect(onChangeSpy).to.have.been.calledWith({
@@ -860,29 +860,29 @@ describe('Select', function() {
860860
});
861861

862862

863-
it('should render dropdown when focused', function() {
863+
it('should render dropdown when focused', async function() {
864864

865865
// when
866866
const { container } = createSelect({ field: { ...defaultField, searchable: true } });
867867

868868
const filterInput = container.querySelector('input[type="text"]');
869869

870870
// then
871-
let selectAnchor = container.querySelector('.fjs-select-anchor');
871+
const selectAnchor = container.querySelector('.fjs-select-anchor');
872872
expect(selectAnchor).to.exist;
873873

874874
let dropdownList = container.querySelector('.fjs-dropdownlist');
875875
expect(dropdownList).to.not.exist;
876876

877-
fireEvent.focus(filterInput);
877+
await act(() => fireEvent.focus(filterInput));
878878

879879
dropdownList = container.querySelector('.fjs-dropdownlist');
880880
expect(dropdownList).to.exist;
881881

882882
});
883883

884884

885-
it('should filter dropdown', function() {
885+
it('should filter dropdown', async function() {
886886

887887
// when
888888
const eventBusFireSpy = spy();
@@ -894,15 +894,15 @@ describe('Select', function() {
894894
const { container } = createSelect({ field, services: { eventBus } });
895895

896896
const filterInput = container.querySelector('input[type="text"]');
897-
fireEvent.focus(filterInput);
897+
await act(() => fireEvent.focus(filterInput));
898898

899899
const dropdownList = container.querySelector('.fjs-dropdownlist');
900900

901901
// then
902902
let listItems = dropdownList.querySelectorAll('.fjs-dropdownlist-item');
903903
expect(listItems.length).to.equal(2);
904904

905-
fireEvent.input(filterInput, { target: { value: 'Ger' } });
905+
await act(() => fireEvent.input(filterInput, { target: { value: 'Ger' } }));
906906

907907
listItems = dropdownList.querySelectorAll('.fjs-dropdownlist-item');
908908
expect(listItems.length).to.equal(1);
@@ -918,7 +918,7 @@ describe('Select', function() {
918918

919919
describe('interaction', function() {
920920

921-
it('should set value through dropdown', function() {
921+
it('should set value through dropdown', async function() {
922922

923923
// given
924924
const onChangeSpy = spy();
@@ -932,10 +932,10 @@ describe('Select', function() {
932932
const filterInput = container.querySelector('input[type="text"]');
933933

934934
// when
935-
fireEvent.focus(filterInput);
935+
await act(() => fireEvent.focus(filterInput));
936936

937937
const germanSelector = container.querySelector('.fjs-dropdownlist .fjs-dropdownlist-item');
938-
fireEvent.mouseDown(germanSelector);
938+
await act(() => fireEvent.mouseDown(germanSelector));
939939

940940
// then
941941
expect(onChangeSpy).to.have.been.calledWith({
@@ -945,7 +945,7 @@ describe('Select', function() {
945945
});
946946

947947

948-
it('should not set value through filter only', function() {
948+
it('should not set value through filter only', async function() {
949949

950950
// given
951951
const onChangeSpy = spy();
@@ -959,16 +959,16 @@ describe('Select', function() {
959959
const filterInput = container.querySelector('input[type="text"]');
960960

961961
// when
962-
fireEvent.focus(filterInput);
963-
fireEvent.input(filterInput, { target: { value: 'English' } });
964-
fireEvent.blur(filterInput);
962+
await act(() => fireEvent.focus(filterInput));
963+
await act(() => fireEvent.input(filterInput, { target: { value: 'English' } }));
964+
await act(() => fireEvent.blur(filterInput));
965965

966966
// then
967967
expect(onChangeSpy).to.not.have.been.called;
968968
});
969969

970970

971-
it('should clear', function() {
971+
it('should clear', async function() {
972972

973973
// given
974974
const onChangeSpy = spy();
@@ -983,7 +983,7 @@ describe('Select', function() {
983983
const cross = container.querySelector('.fjs-select-cross');
984984

985985
// when
986-
fireEvent.mouseDown(cross);
986+
await act(() => fireEvent.mouseDown(cross));
987987

988988
// then
989989
expect(onChangeSpy).to.have.been.calledWith({
@@ -995,7 +995,7 @@ describe('Select', function() {
995995
});
996996

997997

998-
it('should not submit form on enter', function() {
998+
it('should not submit form on enter', async function() {
999999

10001000
// given
10011001
const onSubmitSpy = spy();
@@ -1011,8 +1011,8 @@ describe('Select', function() {
10111011
// when
10121012
const input = container.querySelector('.fjs-input');
10131013

1014-
fireEvent.focus(input);
1015-
fireEvent.keyDown(input, { key: 'Enter', code: 'Enter' });
1014+
await act(() => fireEvent.focus(input));
1015+
await act(() => fireEvent.keyDown(input, { key: 'Enter', code: 'Enter' }));
10161016

10171017
// then
10181018

@@ -1219,7 +1219,7 @@ describe('Select', function() {
12191219
const filterInput = screen.getByLabelText('Language');
12201220

12211221
// when
1222-
fireEvent.focus(filterInput);
1222+
await act(() => fireEvent.focus(filterInput));
12231223

12241224
// then
12251225
await expectNoViolations(container);

0 commit comments

Comments
 (0)