1

I am unit testing a get request that has two querystring params, I can't for the life of me figure out how to write the expect get correctly

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);
    });

results in this error

Error: Unexpected request: GET CostEffectiveness/GetCostEffectivenessChartData?effectiveTime=2015-05-01T15:33:11.590Z&fiscalYear=2014 Expected GET /CostEffectiveness/GetCostEffectivenessChartData\?effectiveTime=*\&fiscalYear=2014/

can any body help me out please!!!

2
  • 1
    I think this should be =.*? rather than =* Commented May 1, 2015 at 15:44
  • YES!!!! @ExplosionPills Commented May 1, 2015 at 15:46

1 Answer 1

1

Your request regex has =* which is "zero or more =" which is not the format you want. Instead you can use =.*? which is "= followed by zero or more characters, reluctantly"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.