Files
cypress/packages/socket/test/socket_spec.js
Ben Kucera fbd523615e [internal] Lint typescript, json, new eslint rules (#4449)
* temp 07/01/19 [skip ci] main lint files

* use lint-staged scripts

* fix all auto-fixable eslint errors

* manually fix lint issues in files

* temp 07/01/19 [skip ci]

* bump eslint plugin versions, update circle.yml

* [lint fix] remaining js files

* update vscode/settings.json

* add back stop-only

* use stop-only for linting .onlys

* fix verify_spec, build_spec

* update json plugin

* relint & apply corrections

* fix appveyor.yml not cleansing env vars (very bad)

* dont echo commit message in appveyor script

* retry build &

* re-add & upgrade lint-staged

* update contributing docs

* only let stop-only catch staged changes
2019-07-12 13:59:44 -04:00

51 lines
1.4 KiB
JavaScript

/* global describe, it, context */
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')
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(process.cwd(), 'node_modules', '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(process.cwd(), 'node_modules', '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()
})
})
})
})