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