我正在测试一个有两个查询字符串的获取请求的单元,我不能在我的生活中弄清楚如何写出期望得到正确的
describe('CostEffectivenessService#getCostEffectivenessChartData', function() {
it('should request correct url', function() {
expect(api.GET_COST_EFFECTIVENESS_CHART_DATA).toBe('CostEffectiveness/GetCostEffectivenessChartData');
});
it('should get cost effectiveess chart data', function() {
$httpBackend.expectGET(/CostEffectiveness\/GetCostEffectivenessChartData\?effectiveTime=*\&fiscalYear=2014/)
.respond([{}, {}, {}, {}]);
var promise = costEffectivenessService.getCostEffectivenessChartData(2014),
results = null;
promise.then(function(res) {
results = res;
});
$httpBackend.flush();
expect(results.lengths).toBe(4);
});
导致此错误
错误:意外请求:GET CostEffectiveness / GetCostEffectivenessChartData?effectiveTime = 2015-05-01T15:33:11.590Z& financialYear = 2014 预期GET / CostEffectiveness / GetCostEffectivenessChartData \?effectiveTime = * \& fiscalYear = 2014 /
任何人都可以帮帮我!!!
答案 0 :(得分:1)
您的请求正则表达式=*
是"零或更多=
"这不是你想要的格式。相反,您可以使用=.*?
" =
后跟零个或多个字符,不情愿地"