Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

promise-socket

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-socket - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

6

CHANGELOG.md
# Changelog
## v0.0.2 2017-06-22
* Upgraded chai@4.0.2, chai-as-promised@7.0.0, promise-duplex@0.1.2,
snazzy@7.0.0, standard@10.0.2, tap@10.5.1, tap-given@0.4.1
* Bugfixes for tests
## v0.0.1 2017-03-12
* Initial release

33

package.json
{
"name": "promise-socket",
"version": "0.0.1",
"version": "0.0.2",
"description": "Return promise for socket stream",

@@ -26,14 +26,12 @@ "main": "lib/promise-socket.js",

"any-promise": "^1.3.0",
"promise-duplex": "^0.1.0"
"promise-duplex": "^0.1.2"
},
"devDependencies": {
"chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"delay": "^1.3.1",
"nyc": "^10.1.2",
"onchange": "^3.2.1",
"snazzy": "^6.0.0",
"standard": "^9.0.1",
"tap": "^10.3.0",
"tap-given": "^0.2.0"
"chai": "^4.0.2",
"chai-as-promised": "^7.0.0",
"delay": "^2.0.0",
"snazzy": "^7.0.0",
"standard": "^10.0.2",
"tap": "^10.5.1",
"tap-given": "^0.4.1"
},

@@ -43,4 +41,15 @@ "scripts": {

"test-coverage": "npm test -- --coverage",
"test-onchange-lcovonly": "onchange '**/*.js' -- npm run -s test-coverage -- -R silent --coverage-report lcovonly"
"test-onchange-lcovonly": "npm run -s test-coverage -- -R min --coverage-report lcovonly; onchange '**/*.js' -- npm run -s test-coverage -- -R min --coverage-report lcovonly"
},
"standard": {
"globals": [
"After",
"And",
"Feature",
"Given",
"Scenario",
"Then",
"When"
]
},
"nyc": {

@@ -47,0 +56,0 @@ "exclude": []

'use strict'
/* global Feature, Scenario, Given, When, Then */
const t = require('tap')

@@ -34,62 +33,77 @@ require('tap-given')(t)

resume () {}
setTimeout (timeout) {
setTimeout(() => this.emit('end'), timeout)
}
}
Scenario('Connect', function () {
Scenario('Connect', () => {
let promise
let promiseSocket
let socket
Given('Socket object', () => {
this.socket = new MockSocket()
socket = new MockSocket()
})
Given('PromiseSocket object', () => {
this.promiseSocket = new PromiseSocket(this.socket)
And('PromiseSocket object', () => {
promiseSocket = new PromiseSocket(socket)
})
When('I call connect method', () => {
this.promise = this.promiseSocket.connect()
promise = promiseSocket.connect()
})
When('connect event is emitted', () => {
this.socket.emit('connect')
And('connect event is emitted', () => {
socket.emit('connect')
})
Then('promise is fulfilled', () => {
return this.promise.should.eventually.be.undefined
return promise.should.eventually.be.undefined
})
})
Scenario('Connect for socket with error', function () {
Scenario('Connect for socket with error', () => {
let promise
let promiseSocket
let socket
Given('Socket object', () => {
this.socket = new MockSocket()
socket = new MockSocket()
})
Given('PromiseSocket object', () => {
this.promiseSocket = new PromiseSocket(this.socket)
And('PromiseSocket object', () => {
promiseSocket = new PromiseSocket(socket)
})
When('I call connect method', () => {
this.promise = this.promiseSocket.connect({host: 'badhost'})
promise = promiseSocket.connect({host: 'badhost'})
})
Then('promise is rejected', () => {
return this.promise.should.be.rejectedWith(Error, 'badhost')
return promise.should.be.rejectedWith(Error, 'badhost')
})
})
Scenario('Set timeout for socket', function () {
Scenario('Set timeout for socket', () => {
let promise
let promiseSocket
let socket
Given('Socket object', () => {
this.socket = new MockSocket()
socket = new MockSocket()
})
Given('PromiseSocket object', () => {
this.promiseSocket = new PromiseSocket(this.stream)
And('PromiseSocket object', () => {
promiseSocket = new PromiseSocket(socket)
})
When('I subscribe for end event', () => {
this.promise = this.promiseSocket.once('end')
promise = promiseSocket.once('end')
})
When('I set timeout for socket', () => {
this.promiseSocket.setTimeout(500)
And('I set timeout for socket', () => {
promiseSocket.setTimeout(500)
})
When('I wait for more that timeout', () => {
And('I wait for more that timeout', () => {
return delay(1000)

@@ -99,28 +113,32 @@ })

Then('socket is ended', () => {
return this.promise.should.be.fulfilled
return promise.should.be.fulfilled
})
})
Scenario('Set timeout for socket two times', function () {
Scenario('Set timeout for socket two times', () => {
let promise
let promiseSocket
let socket
Given('Socket object', () => {
this.socket = new MockSocket()
socket = new MockSocket()
})
Given('PromiseSocket object', () => {
this.promiseSocket = new PromiseSocket(this.stream)
And('PromiseSocket object', () => {
promiseSocket = new PromiseSocket(socket)
})
When('I subscribe for end event', () => {
this.promise = this.promiseSocket.once('end')
promise = promiseSocket.once('end')
})
When('I set timeout for socket first time', () => {
this.promiseSocket.setTimeout(2000)
And('I set timeout for socket first time', () => {
promiseSocket.setTimeout(2000)
})
When('I set timeout for socket another time', () => {
this.promiseSocket.setTimeout(500)
And('I set timeout for socket another time', () => {
promiseSocket.setTimeout(500)
})
When('I wait for more that timeout', () => {
And('I wait for more that timeout', () => {
return delay(1000)

@@ -130,5 +148,5 @@ })

Then('socket is ended', () => {
return this.promise.should.be.fulfilled
return promise.should.be.fulfilled
})
})
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc