aboutsummaryrefslogtreecommitdiffstats
path: root/helpers/FakeHttpProvider2.js
blob: 0f26d84b7b759bf2b5651e26b71ebc473fbf8671 (plain) (blame)
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
var FakeHttpProvider = require('./FakeHttpProvider');

var FakeHttpProvider2 = function () {
    this.counter = 0;
    this.resultList = [];
};

FakeHttpProvider2.prototype = new FakeHttpProvider();
FakeHttpProvider2.prototype.constructor = FakeHttpProvider2;

FakeHttpProvider2.prototype.injectResultList = function (list) {
    this.resultList = list;
};

FakeHttpProvider2.prototype.getResponse = function () {
    var result = this.resultList[this.counter];
    this.counter++;
    if (result.type === 'batch') {
        this.injectBatchResults(result.result);
    } else {
        this.injectResult(result.result);
    }
    return this.response;
};

module.exports = FakeHttpProvider2;