Skip to content

Commit

Permalink
test: use waitFor for editor variables test
Browse files Browse the repository at this point in the history
  • Loading branch information
barmac committed May 24, 2024
1 parent 8d4051c commit 5f97076
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/dmn-js-literal-expression/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"literal expression"
],
"devDependencies": {
"@testing-library/dom": "^10.1.0",
"dmn-font": "^0.6.2",
"inferno-test-utils": "~5.6.2"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { triggerInputEvent } from 'dmn-js-shared/test/util/EventUtil';

import TestContainer from 'mocha-test-container-support';

import { waitFor } from '@testing-library/dom';

import literalExpressionXML from '../../literal-expression.dmn';

import CoreModule from 'src/core';
Expand Down Expand Up @@ -98,7 +100,7 @@ describe('textarea editor', function() {
await changeInput(document.activeElement, 'Var');

// then
return expectEventually(() => {
return waitFor(() => {
const options = testContainer.querySelectorAll('[role="option"]');

expect(options).to.exist;
Expand Down Expand Up @@ -135,16 +137,3 @@ async function act(fn) {
});
});
}

async function expectEventually(fn) {
for (let i = 0; i < 20; i++) {
try {
await fn();
return;
} catch {
await act(() => {});
}
}

await fn();
}

0 comments on commit 5f97076

Please sign in to comment.