overleaf/services/web/test/frontend/features/chat/components/stubs.js
Miguel Serrano 3b1c4e19a4 Merge pull request #3300 from overleaf/msm-chat-react-store
React chat store

GitOrigin-RevId: 204009eb5798b02a41e621b33b05ef0cb9d10b15
2020-11-25 03:04:29 +00:00

41 lines
937 B
JavaScript

import sinon from 'sinon'
import { resetChatStore } from '../../../../../frontend/js/features/chat/store/chat-store-effect'
export function stubUIConfig() {
window.uiConfig = {
chatMessageBorderSaturation: '85%',
chatMessageBorderLightness: '40%',
chatMessageBgSaturation: '85%',
chatMessageBgLightness: '40%'
}
}
export function tearDownUIConfigStubs() {
delete window.uiConfig
}
export function stubMathJax() {
window.MathJax = {
Hub: {
Queue: sinon.stub(),
config: { tex2jax: { inlineMath: [['$', '$']] } }
}
}
}
export function tearDownMathJaxStubs() {
delete window.MathJax
}
export function stubChatStore({ user }) {
window._ide = { socket: { on: sinon.stub(), off: sinon.stub() } }
window.dispatchEvent = sinon.stub()
window.user = user
resetChatStore()
}
export function tearDownChatStore() {
delete window._ide
delete window.dispatchEvent
delete window.user
}