Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

api.js 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (c) 2012 Mathieu Turcotte
  3. * Licensed under the MIT license.
  4. */
  5. var sinon = require('sinon');
  6. var backoff = require('../index');
  7. exports["API"] = {
  8. "backoff.fibonnaci should be a function that returns a backoff instance": function(test) {
  9. test.ok(backoff.fibonacci, 'backoff.fibonacci should be defined.');
  10. test.equal(typeof backoff.fibonacci, 'function',
  11. 'backoff.fibonacci should be a function.');
  12. test.equal(backoff.fibonacci().constructor.name, 'Backoff');
  13. test.done();
  14. },
  15. "backoff.exponential should be a function that returns a backoff instance": function(test) {
  16. test.ok(backoff.exponential, 'backoff.exponential should be defined.');
  17. test.equal(typeof backoff.exponential, 'function',
  18. 'backoff.exponential should be a function.');
  19. test.equal(backoff.exponential().constructor.name, 'Backoff');
  20. test.done();
  21. },
  22. "backoff.call should be a function that returns a FunctionCall instance": function(test) {
  23. var fn = function() {};
  24. var callback = function() {};
  25. test.ok(backoff.Backoff, 'backoff.call should be defined.');
  26. test.equal(typeof backoff.call, 'function',
  27. 'backoff.call should be a function.');
  28. test.equal(backoff.call(fn, 1, 2, 3, callback).constructor.name,
  29. 'FunctionCall');
  30. test.done();
  31. },
  32. "backoff.Backoff should be defined and a function": function(test) {
  33. test.ok(backoff.Backoff, 'backoff.Backoff should be defined.');
  34. test.equal(typeof backoff.Backoff, 'function',
  35. 'backoff.Backoff should be a function.');
  36. test.done();
  37. },
  38. "backoff.FunctionCall should be defined and a function": function(test) {
  39. test.ok(backoff.FunctionCall,
  40. 'backoff.FunctionCall should be defined.');
  41. test.equal(typeof backoff.FunctionCall, 'function',
  42. 'backoff.FunctionCall should be a function.');
  43. test.done();
  44. },
  45. "backoff.FibonacciStrategy should be defined and a function": function(test) {
  46. test.ok(backoff.FibonacciStrategy,
  47. 'backoff.FibonacciStrategy should be defined.');
  48. test.equal(typeof backoff.FibonacciStrategy, 'function',
  49. 'backoff.FibonacciStrategy should be a function.');
  50. test.done();
  51. },
  52. "backoff.ExponentialStrategy should be defined and a function": function(test) {
  53. test.ok(backoff.ExponentialStrategy,
  54. 'backoff.ExponentialStrategy should be defined.');
  55. test.equal(typeof backoff.ExponentialStrategy, 'function',
  56. 'backoff.ExponentialStrategy should be a function.');
  57. test.done();
  58. }
  59. };