Currently, I am in the process of developing a new Resource utilizing AngularJS that falls under the category of Person. After successfully creating this resource, my goal is to retrieve the id associated with the new resource from the server.
it('should obtain the latest Person id post addition', inject(function($httpBackend, Person) {
$httpBackend.whenPOST('http://api.example.com/Persons').respond({ "id" : 32});
var newPerson = new Person();
newPerson.$save();
expect(newPerson.id).toEquals(32);
}));
Upon running my code in Karma, I encounter an error message stating "Expected undefined to be 32."
I believed that my code excerpt closely resembled the example provided in the $Resource documentation, specifically at the conclusion of the Credit Card code snippet.
Could you offer any insights as to where I may have gone wrong?