mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-03-30 06:11:05 +00:00
38 lines
807 B
JavaScript
38 lines
807 B
JavaScript
/* 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/switch')
|
|
|
|
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'
|
|
])
|
|
})
|
|
})
|
|
})
|