This repository has been archived by the owner on Feb 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: better support for interface closing
chore: update deps chore: remove test on pre-push chore: remove non jenkins ci files chore: fix aegir test commands chore: fix linting fix: make callback optional fix: improve stability
- Loading branch information
Showing
11 changed files
with
201 additions
and
134 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const chai = require('chai') | ||
chai.use(require('dirty-chai')) | ||
chai.use(require('chai-checkmark')) | ||
const expect = chai.expect | ||
const sinon = require('sinon') | ||
|
||
const spdy = require('spdy-transport') | ||
const pair = require('pull-pair/duplex') | ||
const toStream = require('pull-stream-to-stream') | ||
|
||
const Muxer = require('../src/muxer') | ||
|
||
describe('multiplex-muxer', () => { | ||
let muxer | ||
let spdyMuxer | ||
|
||
afterEach(() => { | ||
sinon.restore() | ||
}) | ||
|
||
it('can be created', () => { | ||
const p = pair() | ||
spdyMuxer = spdy.connection.create(toStream(p), { | ||
protocol: 'spdy', | ||
isServer: false | ||
}) | ||
muxer = new Muxer(p, spdyMuxer) | ||
}) | ||
|
||
it('catches newStream errors', (done) => { | ||
sinon.stub(spdyMuxer, 'request').callsFake((_, cb) => { | ||
cb(new Error('something bad happened')) | ||
}) | ||
|
||
muxer.newStream((err) => { | ||
expect(err).to.exist() | ||
expect(err.message).to.equal('something bad happened') | ||
done() | ||
}) | ||
}) | ||
|
||
it('can get destroyed', (done) => { | ||
const spy = sinon.spy(spdyMuxer, 'destroyStreams') | ||
expect(2).checks(done) | ||
|
||
muxer.end((err) => { | ||
expect(err).to.not.exist().mark() | ||
|
||
// End it again to test accidental duplicate close | ||
muxer.end((err) => { | ||
expect(spy.callCount).to.eql(2) | ||
expect(err).to.not.exist().mark() | ||
}) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.