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