Skip to content

Commit 869433f

Browse files
committed
fixing test that went rogue when rendering its template
1 parent b121977 commit 869433f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/LiveComponent/assets/test/controller/render.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'use strict';
1111

1212
import { clearDOM } from '@symfony/stimulus-testing';
13-
import { initLiveComponent, startStimulus } from '../tools';
13+
import { initLiveComponent, mockRerender, startStimulus } from '../tools';
1414
import { createEvent, fireEvent, getByLabelText, getByText, waitFor } from '@testing-library/dom';
1515
import userEvent from '@testing-library/user-event';
1616
import fetchMock from 'fetch-mock-jest';
@@ -47,13 +47,13 @@ describe('LiveController rendering Tests', () => {
4747
const data = { name: 'Ryan' };
4848
const { element, controller } = await startStimulus(template(data));
4949

50-
fetchMock.get('http://localhost/_components/my_component?name=Ryan', {
51-
html: '<div>aloha!</div>',
52-
data: { name: 'Kevin' }
50+
mockRerender({ name: 'Ryan' }, template, (data) => {
51+
// change the data on the server
52+
data.name = 'Kevin';
5353
});
5454
getByText(element, 'Reload').click();
5555

56-
await waitFor(() => expect(element).toHaveTextContent('aloha!'));
56+
await waitFor(() => expect(element).toHaveTextContent('Name: Kevin'));
5757
expect(controller.dataValue).toEqual({name: 'Kevin'});
5858
});
5959

0 commit comments

Comments
 (0)