import WebSDK, { WebSDKBOM } from '../src'

it('test YY', () => {
  window.YY = {
    sayHello(name) {
      return true
    }
  }
  expect(WebSDK('sayHello', 'youxiu')).toBe(true)
  delete window.YY
})
WebSDKBOM.keysConfig({
  code: 'key'
})
describe('test moschat', () => {
  test('moschat sayHello，返回undefined', () => {
    expect(WebSDK('setName', 'youxiu')).not
    window.moschat = {
      setTitle(name) {
        return true
      },
      getVersion() {
        return '1.2.1'
      }
    }
  })
  describe('moschat 重写catchError方法，返回false', () => {
    test('moschat catchError方法', () => {
      // 重写错误方法
      WebSDKBOM.catchError = function(error) {
        return false
      }
      expect(WebSDK('setName', 'youxiu')).toBe(false)
    })
    test('moschat getVersion方法', () => {
      expect(WebSDK('getVersion')).toBe('1.2.1')
      // delete window.moschat
      console.log('-------window-', window.moschat)
    })
  })
})

