hc 12 lat temu
rodzic
commit
4ebae56905
2 zmienionych plików z 35 dodań i 6 usunięć
  1. 1 1
      test/adapter.js
  2. 34 5
      test/util.js

+ 1 - 1
test/adapter.js

@@ -1,7 +1,7 @@
 describe('adapter', function() {
 
   it('sets browerisms', function() {
-    expect(exports.util.browserisms).to.match(/^Firefox||Webkit$/)
+    expect(exports.util.browserisms).to.match(/^Firefox||Webkit$/);
   })
 
   it('sets RTCPeerConnection', function() {

+ 34 - 5
test/util.js

@@ -4,11 +4,40 @@ describe('util', function() {
 
   })
 
-  it('extend')
-  it('extend')
-  it('pack')
-  it('unpack')
-  it('randomPort')
+  /*
+   *  extend overwrites keys if already exists
+   *  leaves existing keys alone otherwise
+   */
+  it('extend', function() {
+    var a = {a: 1, b: 2, c: 3, d: 4}
+      , b = {d: 2};
+    util.extend(b, a);
+    expect(b).to.eql(a);
+    expect(b.d).to.be.equal(4);
+    b = {z: 2};
+    util.extend(b, a);
+    expect(b.z).to.be.equal(2);
+  })
+
+  it('pack', function() {
+    expect(util.pack).to.be.equal(BinaryPack.pack);
+  })
+
+  it('unpack', function() {
+    expect(util.unpack).to.be.equal(BinaryPack.unpack);
+  })
+
+  it('randomPort', function() {
+    var i = 0
+      , ports = {};
+    while(i < 25) {
+      var p = util.randomPort();
+      if (ports[p]) throw new Error('randomPort not so random')
+      ports[p] = 1;
+      i++;
+    }
+  })
+
   it('log')
   it('setZeroTimeout')
   it('blobToArrayBuffer')