2

I really need help with faking ngResource call.
What I mean:

public getResource(fake: boolean) {
  return this.$resource("/my-url/:param",
    {
      param: "@param"
    },
    {
      get: this.getConfig(fake),
    },
  );
}

private getConfig(fake: boolean) {
  return fake ? this.mockResponse() : { method: "GET", isArray: false };
}

private this.mockResponse() {
  return {
    method: "GET", 
    url: "",
    interceptor: {
      response: () => {
       return  { key: "value" },
      }
    },
  };
} 

So, this code, returns needed object, but it also makes call. I need it to return mocked object without any call.
Thank you!

John Doe
  • 547
  • 3
  • 11

0 Answers0