Search code examples
angularjsjasminerestangular

jasmine test a Restangular response


I'm calling

Restangular.all('resource').getList() 

and I want to test that the results are as expected.

In my test, I want to make this work

expectedResp = { one: 1, two: 2, three: 3 };
expect(resp).toEqual(expectedResp);

The problem is that the resp from restangular is restangularized, meaning it contains a bunch of members in addition to the data returned from the rest call.


Solution

  • It should be

    expectedResp = { one: 1, two: 2, three: 3 };
    expect(resp).toEqual(jasmine.objectContaining(expectedResp));