本文整理匯總了TypeScript中test/lib/common.sinon.stub方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript sinon.stub方法的具體用法?TypeScript sinon.stub怎麽用?TypeScript sinon.stub使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類test/lib/common.sinon
的用法示例。
在下文中一共展示了sinon.stub方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: beforeEach
beforeEach(angularMocks.inject(($rootScope, $controller, $q) => {
ctx.$q = $q;
ctx.scope = $rootScope.$new();
ctx.target = {target: ''};
ctx.panelCtrl = {
panel: {
targets: [ctx.target]
}
};
ctx.panelCtrl.refresh = sinon.spy();
ctx.datasource.getAggregators = sinon.stub().returns(ctx.$q.when([]));
ctx.datasource.getFilterTypes = sinon.stub().returns(ctx.$q.when([]));
ctx.ctrl = $controller(OpenTsQueryCtrl, {$scope: ctx.scope}, {
panelCtrl: ctx.panelCtrl,
datasource: ctx.datasource,
target: ctx.target,
});
ctx.scope.$digest();
}));
示例2: Emitter
angularMocks.inject(($rootScope, $q, $location, $injector) => {
ctx.$q = $q;
ctx.$rootScope = $rootScope;
ctx.$location = $location;
ctx.variableSrv = $injector.get('variableSrv');
ctx.variableSrv.init({
templating: { list: [] },
events: new Emitter(),
updateSubmenuVisibility: sinon.stub(),
});
ctx.$rootScope.$digest();
})
示例3: beforeEach
beforeEach(function() {
ctx.ctrl.target.target = 'scaleToSeconds(#A)';
ctx.ctrl.datasource.metricFindQuery = sinon.stub().returns(ctx.$q.when([{expandable: false}]));
ctx.ctrl.parseTarget();
ctx.ctrl.panelCtrl.panel.targets = [ {
target: 'nested.query.count',
refId: 'A'
}];
ctx.ctrl.updateModelTarget();
});
示例4: beforeEach
beforeEach(function() {
ctx.ctrl.target.target = 'metrics.a.count';
ctx.ctrl.target.refId = 'A';
ctx.ctrl.datasource.metricFindQuery = sinon.stub().returns(ctx.$q.when([{expandable: false}]));
ctx.ctrl.parseTarget();
ctx.ctrl.panelCtrl.panel.targets = [
ctx.ctrl.target, {target: 'sumSeries(#A)', refId: 'B'}
];
ctx.ctrl.updateModelTarget();
});
示例5: beforeEach
beforeEach(angularMocks.inject(($rootScope, $controller, $q) => {
ctx.$q = $q;
ctx.scope = $rootScope.$new();
ctx.datasource.metricFindQuery = sinon.stub().returns(ctx.$q.when([]));
ctx.panelCtrl = {panel: {}};
ctx.panelCtrl.refresh = sinon.spy();
ctx.target = {target: {}};
ctx.ctrl = $controller(InfluxQueryCtrl, {$scope: ctx.scope}, {
panelCtrl: ctx.panelCtrl,
target: ctx.target,
datasource: ctx.datasource
});
}));
示例6: beforeEach
beforeEach(angularMocks.inject(($rootScope, $controller, $q) => {
ctx.$q = $q;
ctx.scope = $rootScope.$new();
ctx.target = {target: 'aliasByNode(scaleToSeconds(test.prod.*,1),2)'};
ctx.datasource.metricFindQuery = sinon.stub().returns(ctx.$q.when([]));
ctx.panelCtrl = {panel: {}};
ctx.panelCtrl.refresh = sinon.spy();
ctx.ctrl = $controller(OpenfalconQueryCtrl, {$scope: ctx.scope}, {
panelCtrl: ctx.panelCtrl,
datasource: ctx.datasource,
target: ctx.target
});
ctx.scope.$digest();
}));
示例7: beforeEach
beforeEach(angularMocks.inject(($controller, $q) => {
deferred = $q.defer();
historySrv.getHistoryList.returns(deferred.promise);
ctx.ctrl = $controller(HistoryListCtrl, {
historySrv,
$rootScope,
$scope: ctx.scope,
}, {
dashboard: {
id: 2,
version: 3,
formatDate: sinon.stub().returns('date'),
}
});
}));
示例8: moment
scenario.setup(() => {
scenario.variableModel = {
type: 'interval',
query: '1s,2h,5h,1d',
name: 'test',
auto: true,
auto_count: 10,
};
var range = {
from: moment(new Date())
.subtract(7, 'days')
.toDate(),
to: new Date(),
};
ctx.timeSrv.timeRange = sinon.stub().returns(range);
ctx.templateSrv.setGrafanaVariable = sinon.spy();
});
示例9: beforeEach
beforeEach(function() {
var range = {
from: moment(new Date()).subtract(7, 'days').toDate(),
to: new Date()
};
ctx.timeSrv.timeRange = sinon.stub().returns(range);
ctx.templateSrv.setGrafanaVariable = sinon.spy();
var variableModel1 = {type: 'interval', query: '1s,2h,5h,1d', name: 'variable1', auto: true, auto_count: 10 };
variable1 = ctx.variableSrv.createVariableFromModel(variableModel1);
ctx.variableSrv.addVariable(variable1);
var variableModel2 = {type: 'interval', query: '1s,2h,5h', name: 'variable2', auto: true, auto_count: 1000 };
variable2 = ctx.variableSrv.createVariableFromModel(variableModel2);
ctx.variableSrv.addVariable(variable2);
ctx.variableSrv.updateOptions(variable1);
ctx.variableSrv.updateOptions(variable2);
ctx.$rootScope.$digest();
});