mirror of
https://github.com/socketio/socket.io.git
synced 2026-04-30 03:00:39 -04:00
Added changes to reflect socket.io-parser's async encoding, and use of has-binarydata to check the event type of an event. Next added browser tests for sending and receiving of binary data via arraybuffers. Then added blob tests and blob recognition. To make blobs fully work (and Files as well), had to add packet buffering to client so that slow-encoding blobs are still sent before other events. I fixed a stupid bug I had added where I used the indexof module (for old browsers) on a string somewhere instead of an array). This was causing old IE to receive all events twice. Old iphone tests were still failing so I updated tests to reflect that some browsers can receive a blob but not construct them. Finally, reduced build size by adding the "browser" field to package.json and making browserify less confused.
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
|
|
var old = global.location;
|
|
var loc = {};
|
|
var url = require('../lib/url');
|
|
var expect = require('expect.js');
|
|
|
|
describe('url', function(){
|
|
|
|
it('works with relative paths', function(){
|
|
loc.hostname = 'woot.com';
|
|
loc.protocol = 'https:';
|
|
var parsed = url('/test', loc);
|
|
expect(parsed.host).to.be('woot.com');
|
|
expect(parsed.protocol).to.be('https');
|
|
});
|
|
|
|
it('works with no protocol', function(){
|
|
loc.protocol = 'http:';
|
|
var parsed = url('localhost:3000', loc);
|
|
expect(parsed.host).to.be('localhost');
|
|
expect(parsed.port).to.be('3000');
|
|
expect(parsed.protocol).to.be('http');
|
|
});
|
|
|
|
it('ignores default ports for unique url ids', function(){
|
|
var id1 = url('http://google.com:80/');
|
|
var id2 = url('http://google.com/');
|
|
var id3 = url('https://google.com/');
|
|
expect(id1.id).to.be(id2.id);
|
|
expect(id1.id).to.not.be(id3.id);
|
|
});
|
|
|
|
it('identifies the namespace', function(){
|
|
loc.protocol = 'http:';
|
|
loc.hostname = 'woot.com';
|
|
|
|
expect(url('/woot').path).to.be('/woot');
|
|
expect(url('http://google.com').path).to.be('/');
|
|
expect(url('http://google.com/').path).to.be('/');
|
|
});
|
|
|
|
});
|