Main.spec.js 450 B

123456789101112131415161718192021
  1. import Vue from 'vue'
  2. import VueNativeSock from '@/Main'
  3. import { Server } from 'mock-socket'
  4. describe("Main.js", () =>{
  5. let mockServer
  6. it ('can be bound to the onopen event', (done) => {
  7. mockServer = new Server('ws://localhost:8080')
  8. Vue.use(VueNativeSock, 'ws://localhost:8080')
  9. let vm = new Vue()
  10. vm.$options.sockets.onopen = (data) => {
  11. expect(data.type).to.equal('open')
  12. mockServer.stop(done)
  13. }
  14. })
  15. })