mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Lightly massage some of the generated JavaScript
This commit is contained in:
parent
31ad9566e6
commit
1867a3f121
19 changed files with 986 additions and 989 deletions
|
@ -1,10 +1,12 @@
|
|||
// Generated by CoffeeScript 2.4.1
|
||||
/*
|
||||
jasmine tests for Snowflake utils
|
||||
*/
|
||||
|
||||
describe('Parse', function() {
|
||||
|
||||
describe('cookie', function() {
|
||||
return it('parses correctly', function() {
|
||||
|
||||
it('parses correctly', function() {
|
||||
expect(Parse.cookie('')).toEqual({});
|
||||
expect(Parse.cookie('a=b')).toEqual({
|
||||
a: 'b'
|
||||
|
@ -30,12 +32,15 @@ describe('Parse', function() {
|
|||
expect(Parse.cookie('key=%26%20')).toEqual({
|
||||
key: '& '
|
||||
});
|
||||
return expect(Parse.cookie('a=\'\'')).toEqual({
|
||||
expect(Parse.cookie('a=\'\'')).toEqual({
|
||||
a: '\'\''
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('address', function() {
|
||||
|
||||
it('parses IPv4', function() {
|
||||
expect(Parse.address('')).toBeNull();
|
||||
expect(Parse.address('3.3.3.3:4444')).toEqual({
|
||||
|
@ -45,9 +50,10 @@ describe('Parse', function() {
|
|||
expect(Parse.address('3.3.3.3')).toBeNull();
|
||||
expect(Parse.address('3.3.3.3:0x1111')).toBeNull();
|
||||
expect(Parse.address('3.3.3.3:-4444')).toBeNull();
|
||||
return expect(Parse.address('3.3.3.3:65536')).toBeNull();
|
||||
expect(Parse.address('3.3.3.3:65536')).toBeNull();
|
||||
});
|
||||
return it('parses IPv6', function() {
|
||||
|
||||
it('parses IPv6', function() {
|
||||
expect(Parse.address('[1:2::a:f]:4444')).toEqual({
|
||||
host: '1:2::a:f',
|
||||
port: 4444
|
||||
|
@ -56,15 +62,17 @@ describe('Parse', function() {
|
|||
expect(Parse.address('[1:2::a:f]:0x1111')).toBeNull();
|
||||
expect(Parse.address('[1:2::a:f]:-4444')).toBeNull();
|
||||
expect(Parse.address('[1:2::a:f]:65536')).toBeNull();
|
||||
return expect(Parse.address('[1:2::ffff:1.2.3.4]:4444')).toEqual({
|
||||
expect(Parse.address('[1:2::ffff:1.2.3.4]:4444')).toEqual({
|
||||
host: '1:2::ffff:1.2.3.4',
|
||||
port: 4444
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
return describe('ipFromSDP', function() {
|
||||
var testCases;
|
||||
testCases = [
|
||||
|
||||
describe('ipFromSDP', function() {
|
||||
|
||||
var testCases = [
|
||||
{
|
||||
// https://tools.ietf.org/html/rfc4566#section-5
|
||||
sdp: "v=0\no=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\ns=SDP Seminar\ni=A Seminar on the session description protocol\nu=http://www.example.com/seminars/sdp.pdf\ne=j.doe@example.com (Jane Doe)\nc=IN IP4 224.2.17.12/127\nt=2873397496 2873404696\na=recvonly\nm=audio 49170 RTP/AVP 0\nm=video 51372 RTP/AVP 99\na=rtpmap:99 h263-1998/90000",
|
||||
|
@ -128,7 +136,8 @@ describe('Parse', function() {
|
|||
expected: void 0
|
||||
}
|
||||
];
|
||||
return it('parses SDP', function() {
|
||||
|
||||
it('parses SDP', function() {
|
||||
var i, len, ref, ref1, results, test;
|
||||
results = [];
|
||||
for (i = 0, len = testCases.length; i < len; i++) {
|
||||
|
@ -143,10 +152,13 @@ describe('Parse', function() {
|
|||
}
|
||||
return results;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('query string', function() {
|
||||
|
||||
it('should parse correctly', function() {
|
||||
expect(Query.parse('')).toEqual({});
|
||||
expect(Query.parse('a=b')).toEqual({
|
||||
|
@ -178,11 +190,12 @@ describe('query string', function() {
|
|||
expect(Query.parse('a+b=c')).toEqual({
|
||||
'a b': 'c'
|
||||
});
|
||||
return expect(Query.parse('a=b+c+d')).toEqual({
|
||||
expect(Query.parse('a=b+c+d')).toEqual({
|
||||
a: 'b c d'
|
||||
});
|
||||
});
|
||||
return it('uses the first appearance of duplicate key', function() {
|
||||
|
||||
it('uses the first appearance of duplicate key', function() {
|
||||
expect(Query.parse('a=b&c=d&a=e')).toEqual({
|
||||
a: 'b',
|
||||
c: 'd'
|
||||
|
@ -201,21 +214,24 @@ describe('query string', function() {
|
|||
a: 'b',
|
||||
'': ''
|
||||
});
|
||||
return expect(Query.parse('a=b&&c=d')).toEqual({
|
||||
expect(Query.parse('a=b&&c=d')).toEqual({
|
||||
a: 'b',
|
||||
'': '',
|
||||
c: 'd'
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Params', function() {
|
||||
|
||||
describe('bool', function() {
|
||||
var getBool;
|
||||
getBool = function(query) {
|
||||
|
||||
var getBool = function(query) {
|
||||
return Params.getBool(Query.parse(query), 'param', false);
|
||||
};
|
||||
return it('parses correctly', function() {
|
||||
|
||||
it('parses correctly', function() {
|
||||
expect(getBool('param=true')).toBe(true);
|
||||
expect(getBool('param')).toBe(true);
|
||||
expect(getBool('param=')).toBe(true);
|
||||
|
@ -223,19 +239,23 @@ describe('Params', function() {
|
|||
expect(getBool('param=0')).toBe(false);
|
||||
expect(getBool('param=false')).toBe(false);
|
||||
expect(getBool('param=unexpected')).toBeNull();
|
||||
return expect(getBool('pram=true')).toBe(false);
|
||||
expect(getBool('pram=true')).toBe(false);
|
||||
});
|
||||
|
||||
});
|
||||
return describe('address', function() {
|
||||
var DEFAULT, getAddress;
|
||||
DEFAULT = {
|
||||
|
||||
describe('address', function() {
|
||||
|
||||
var DEFAULT = {
|
||||
host: '1.1.1.1',
|
||||
port: 2222
|
||||
};
|
||||
getAddress = function(query) {
|
||||
|
||||
var getAddress = function(query) {
|
||||
return Params.getAddress(query, 'addr', DEFAULT);
|
||||
};
|
||||
return it('parses correctly', function() {
|
||||
|
||||
it('parses correctly', function() {
|
||||
expect(getAddress({})).toEqual(DEFAULT);
|
||||
expect(getAddress({
|
||||
addr: '3.3.3.3:4444'
|
||||
|
@ -246,9 +266,11 @@ describe('Params', function() {
|
|||
expect(getAddress({
|
||||
x: '3.3.3.3:4444'
|
||||
})).toEqual(DEFAULT);
|
||||
return expect(getAddress({
|
||||
expect(getAddress({
|
||||
addr: '---'
|
||||
})).toBeNull();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue