Skip to content

Commit 8e5cd8a

Browse files
committed
fix TU
1 parent 25d8306 commit 8e5cd8a

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/FormCollection/Resources/assets/test/controller.test.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
'use strict';
1111

12-
import { Application, Controller } from 'stimulus';
12+
import { Application, Controller } from '@hotwired/stimulus';
1313
import { getByTestId, waitFor } from '@testing-library/dom';
1414
import { clearDOM, mountDOM } from '@symfony/stimulus-testing';
1515
import FormCollectionController from '../src/controller';
@@ -30,29 +30,35 @@ const startStimulus = () => {
3030
const application = Application.start();
3131
application.register('check', CheckController);
3232
application.register('formCollection', FormCollectionController);
33+
34+
return application;
3335
};
3436

3537
describe('FormCollectionController', () => {
36-
let container: HTMLElement;
37-
38-
beforeEach(() => {
39-
container = mountDOM(`
40-
<div class="container" data-controller="check formCollection" data-testid="container">
41-
42-
</div>
43-
`);
44-
});
38+
let application;
4539

4640
afterEach(() => {
4741
clearDOM();
42+
application.stop();
4843
});
4944

5045
it('events', async () => {
51-
expect(getByTestId(container, 'container')).not.toHaveClass('connected');
46+
const container = mountDOM(`
47+
<div
48+
data-testid="container"
49+
data-controller="check formCollection"
50+
class="container">
51+
</div>
52+
`);
53+
5254
expect(getByTestId(container, 'container')).not.toHaveClass('pre-connected');
55+
expect(getByTestId(container, 'container')).not.toHaveClass('connected');
56+
57+
application = startStimulus();
5358

54-
startStimulus();
55-
await waitFor(() => expect(getByTestId(container, 'container')).toHaveClass('connected'));
56-
await waitFor(() => expect(getByTestId(container, 'container')).toHaveClass('pre-connected'));
59+
await waitFor(() => {
60+
expect(getByTestId(container, 'container')).toHaveClass('pre-connected')
61+
expect(getByTestId(container, 'container')).toHaveClass('connected')
62+
});
5763
});
5864
});

0 commit comments

Comments
 (0)