/js/lib/Socket.IO-node/support/expresso/test/assert.test.js

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs · JavaScript · 91 lines · 75 code · 13 blank · 3 comment · 0 complexity · f6fb6b7293716f96652983fc9be7164e MD5 · raw file

  1. /**
  2. * Module dependencies.
  3. */
  4. var assert = require('assert');
  5. module.exports = {
  6. 'assert.eql()': function(){
  7. assert.equal(assert.deepEqual, assert.eql);
  8. },
  9. 'assert.type()': function(){
  10. assert.type('foobar', 'string');
  11. assert.type(2, 'number');
  12. assert.throws(function(){
  13. assert.type([1,2,3], 'string');
  14. });
  15. },
  16. 'assert.includes()': function(){
  17. assert.includes('some random string', 'dom');
  18. assert.throws(function(){
  19. assert.include('some random string', 'foobar');
  20. });
  21. assert.includes(['foo', 'bar'], 'bar');
  22. assert.includes(['foo', 'bar'], 'foo');
  23. assert.includes([1,2,3], 3);
  24. assert.includes([1,2,3], 2);
  25. assert.includes([1,2,3], 1);
  26. assert.throws(function(){
  27. assert.includes(['foo', 'bar'], 'baz');
  28. });
  29. assert.throws(function(){
  30. assert.includes({ wrong: 'type' }, 'foo');
  31. });
  32. },
  33. 'assert.isNull()': function(){
  34. assert.isNull(null);
  35. assert.throws(function(){
  36. assert.isNull(undefined);
  37. });
  38. assert.throws(function(){
  39. assert.isNull(false);
  40. });
  41. },
  42. 'assert.isUndefined()': function(){
  43. assert.isUndefined(undefined);
  44. assert.throws(function(){
  45. assert.isUndefined(null);
  46. });
  47. assert.throws(function(){
  48. assert.isUndefined(false);
  49. });
  50. },
  51. 'assert.isNotNull()': function(){
  52. assert.isNotNull(false);
  53. assert.isNotNull(undefined);
  54. assert.throws(function(){
  55. assert.isNotNull(null);
  56. });
  57. },
  58. 'assert.isDefined()': function(){
  59. assert.isDefined(false);
  60. assert.isDefined(null);
  61. assert.throws(function(){
  62. assert.isDefined(undefined);
  63. });
  64. },
  65. 'assert.match()': function(){
  66. assert.match('foobar', /foo(bar)?/);
  67. assert.throws(function(){
  68. assert.match('something', /rawr/);
  69. });
  70. },
  71. 'assert.length()': function(){
  72. assert.length('test', 4);
  73. assert.length([1,2,3,4], 4);
  74. assert.throws(function(){
  75. assert.length([1,2,3], 4);
  76. });
  77. }
  78. };