2020-12-14 06:44:10 -05:00
|
|
|
import React from 'react'
|
|
|
|
import { render } from '@testing-library/react'
|
|
|
|
import { ApplicationProvider } from '../../../frontend/js/shared/context/application-context'
|
|
|
|
import { EditorProvider } from '../../../frontend/js/shared/context/editor-context'
|
2021-01-14 10:16:54 -05:00
|
|
|
import sinon from 'sinon'
|
2020-12-14 06:44:10 -05:00
|
|
|
|
2021-01-14 10:16:54 -05:00
|
|
|
export function renderWithEditorContext(
|
|
|
|
children,
|
|
|
|
{ user = { id: '123abd' }, projectId } = {}
|
|
|
|
) {
|
2020-12-14 06:44:10 -05:00
|
|
|
window.user = user || window.user
|
|
|
|
window.project_id = projectId != null ? projectId : window.project_id
|
2021-01-14 10:16:54 -05:00
|
|
|
window._ide = {
|
|
|
|
$scope: {
|
|
|
|
project: {
|
|
|
|
owner: {
|
|
|
|
_id: '124abd'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
socket: {
|
|
|
|
on: sinon.stub(),
|
|
|
|
removeListener: sinon.stub()
|
|
|
|
}
|
|
|
|
}
|
2020-12-14 06:44:10 -05:00
|
|
|
return render(
|
|
|
|
<ApplicationProvider>
|
|
|
|
<EditorProvider>{children}</EditorProvider>
|
|
|
|
</ApplicationProvider>
|
|
|
|
)
|
|
|
|
}
|