Skip to content

Commit

Permalink
test: fix flaky test in literal expression
Browse files Browse the repository at this point in the history
  • Loading branch information
barmac committed Oct 16, 2024
1 parent e9227ec commit cb8ef20
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
3 changes: 3 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.4.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 @@ -2,6 +2,8 @@

import { bootstrapModeler, inject } from 'test/helper';

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

import { query as domQuery } from 'min-dom';

import { queryEditor } from 'dmn-js-shared/test/util/EditorUtil';
Expand Down Expand Up @@ -101,19 +103,19 @@ describe('textarea editor', function() {
});


it('should pass variables to editor', async function() {
it('should pass variables to editor', inject(async function(modeling) {

// given
const getVariablesSpy = sinon.spy(variableResolver, 'getVariables');
const editor = queryEditor('.textarea', testContainer);
await changeFocus(editor);

// when
await changeInput(document.activeElement, 'Var');
modeling.editLiteralExpressionText('Var');

// then
expect(getVariablesSpy).to.have.been.called;
});
await waitFor(() => {
expect(getVariablesSpy).to.have.been.called;
});
}));
});

});
Expand All @@ -128,10 +130,6 @@ async function changeInput(input, value) {
await act(() => input.textContent = value);
}

async function changeFocus(editor) {
await act(() => editor.focus());
}

async function act(fn) {
await fn();
return new Promise(resolve => {
Expand Down

0 comments on commit cb8ef20

Please sign in to comment.