Files
cypress/packages/socket/test/socket_spec.js
Zach Bloomquist e2ea5bf663 Fix patch-package (#6583)
* fix patch-package

- don't hoist dependencies that are patched, this way we can be assured the path is always correct
- put all patches in root postinstall so postinstall-postinstall is guaranteed to work

* wip

* Revert "fix patch-package"

This reverts commit 5583f21478.

* use per package patches

* don't ignor engines or silence

* try: make sinon patch devonly

* fix socketspec

* run full ci on this branch

* bump xcode tools to bump mac node version

* also run appveyor

* Revert "run full ci on this branch"

This reverts commit c3e52d09ec.

* Revert "also run appveyor"

This reverts commit bfe7b0499a.
2020-02-28 12:17:54 -05:00

50 lines
1.4 KiB
JavaScript

const fs = require('fs')
const path = require('path')
const server = require('socket.io')
const client = require('socket.io-client')
const expect = require('chai').expect
const pkg = require('../package.json')
const lib = require('../index')
const resolvePkg = require('resolve-pkg')
describe('Socket', function () {
it('exports server', function () {
expect(lib.server).to.eq(server)
})
it('exports client', function () {
expect(lib.client).to.eq(client)
})
context('.getPathToClientSource', function () {
it('returns path to socket.io.js', function () {
const clientPath = path.join(resolvePkg('socket.io-client'), 'dist', 'socket.io.js')
expect(lib.getPathToClientSource()).to.eq(clientPath)
})
it('makes sure socket.io.js actually exists', function (done) {
fs.stat(lib.getPathToClientSource(), done)
})
})
context('.getClientVersion', function () {
it('returns client version', function () {
expect(lib.getClientVersion()).to.eq(pkg.dependencies['socket.io-client'])
})
})
context('.getClientSource', function () {
it('returns client source as a string', function (done) {
const clientPath = path.join(resolvePkg('socket.io-client'), 'dist', 'socket.io.js')
fs.readFile(clientPath, 'utf8', function (err, str) {
if (err) done(err)
expect(lib.getClientSource()).to.eq(str)
done()
})
})
})
})