util.js 957 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. describe('util', function() {
  2. it('inherits', function() {
  3. })
  4. /*
  5. * extend overwrites keys if already exists
  6. * leaves existing keys alone otherwise
  7. */
  8. it('extend', function() {
  9. var a = {a: 1, b: 2, c: 3, d: 4}
  10. , b = {d: 2};
  11. util.extend(b, a);
  12. expect(b).to.eql(a);
  13. expect(b.d).to.be.equal(4);
  14. b = {z: 2};
  15. util.extend(b, a);
  16. expect(b.z).to.be.equal(2);
  17. })
  18. it('pack', function() {
  19. expect(util.pack).to.be.equal(BinaryPack.pack);
  20. })
  21. it('unpack', function() {
  22. expect(util.unpack).to.be.equal(BinaryPack.unpack);
  23. })
  24. it('randomPort', function() {
  25. var i = 0
  26. , ports = {};
  27. while(i < 25) {
  28. var p = util.randomPort();
  29. if (ports[p]) throw new Error('randomPort not so random')
  30. ports[p] = 1;
  31. i++;
  32. }
  33. })
  34. it('log')
  35. it('setZeroTimeout')
  36. it('blobToArrayBuffer')
  37. it('blobToBinaryString')
  38. it('binaryStringToArrayBuffer')
  39. it('randomToken')
  40. });