This repository has been archived by the owner on Aug 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: resolve transport sort order in browsers (#333)
* fix: resolve transport sort order in browsers * fix: update sort logic
- Loading branch information
Showing
2 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
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,37 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const chai = require('chai') | ||
const dirtyChai = require('dirty-chai') | ||
const expect = chai.expect | ||
chai.use(dirtyChai) | ||
|
||
const Switch = require('../src') | ||
|
||
describe('Switch', () => { | ||
describe('.availableTransports', () => { | ||
it('should always sort circuit last', () => { | ||
const switchA = new Switch({}, {}) | ||
const transport = { | ||
filter: (addrs) => addrs | ||
} | ||
const mockPeerInfo = { | ||
multiaddrs: { | ||
toArray: () => ['a', 'b', 'c'] | ||
} | ||
} | ||
|
||
switchA.transports = { | ||
Circuit: transport, | ||
TCP: transport, | ||
WebSocketStar: transport | ||
} | ||
|
||
expect(switchA.availableTransports(mockPeerInfo)).to.eql([ | ||
'TCP', | ||
'WebSocketStar', | ||
'Circuit' | ||
]) | ||
}) | ||
}) | ||
}) |