Skip to content

Commit b4395d7

Browse files
committed
Fix tests
1 parent 4d3ca75 commit b4395d7

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

test/unit/util/vm-manager-hoc.test.jsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ describe('VMManagerHOC', () => {
6060
const WrappedComponent = vmManagerHOC(Component);
6161
const mounted = mount(
6262
<WrappedComponent
63+
fontsLoaded
6364
isLoadingWithId={false}
6465
store={store}
6566
vm={vm}
@@ -75,27 +76,38 @@ describe('VMManagerHOC', () => {
7576
// nextTick needed since vm.loadProject is async, and we have to wait for it :/
7677
process.nextTick(() => expect(mockedOnLoadedProject).toHaveBeenLastCalledWith(LoadingState.LOADING_VM_WITH_ID));
7778
});
78-
test('if there is projectData, the child is rendered', () => {
79+
test('if the fontsLoaded prop becomes true, it loads project data into the vm', () => {
80+
vm.loadProject = jest.fn(() => Promise.resolve());
81+
const mockedOnLoadedProject = jest.fn();
7982
const Component = () => <div />;
8083
const WrappedComponent = vmManagerHOC(Component);
8184
const mounted = mount(
8285
<WrappedComponent
83-
projectData="100"
86+
isLoadingWithId
8487
store={store}
8588
vm={vm}
89+
onLoadedProject={mockedOnLoadedProject}
8690
/>
8791
);
88-
expect(mounted.find('div').length).toBe(1);
92+
mounted.setProps({
93+
fontsLoaded: true,
94+
loadingState: LoadingState.LOADING_VM_WITH_ID,
95+
projectData: '100'
96+
});
97+
expect(vm.loadProject).toHaveBeenLastCalledWith('100');
98+
// nextTick needed since vm.loadProject is async, and we have to wait for it :/
99+
process.nextTick(() => expect(mockedOnLoadedProject).toHaveBeenLastCalledWith(LoadingState.LOADING_VM_WITH_ID));
89100
});
90-
test('if there is no projectData, nothing is rendered', () => {
101+
test('if there is projectData, the child is rendered', () => {
91102
const Component = () => <div />;
92103
const WrappedComponent = vmManagerHOC(Component);
93104
const mounted = mount(
94105
<WrappedComponent
106+
projectData="100"
95107
store={store}
96108
vm={vm}
97109
/>
98110
);
99-
expect(mounted.find('div').length).toBe(0);
111+
expect(mounted.find('div').length).toBe(1);
100112
});
101113
});

0 commit comments

Comments
 (0)