{"push_id":834116319,"size":1,"distinct_size":1,"ref":"refs/heads/Chp_14EnsuringCorrectImplementationOfTheProxyPattern","head":"26c727292e4c0c62eac325034c12bfd2393c0aba","before":"26566716450e31e9d5d7e3312884fa7f9bfd5ff9","commits":[{"sha":"26c727292e4c0c62eac325034c12bfd2393c0aba","author":{"email":"688085edcac35a6f5d4cd9ba4db0e893cb0d2736@gmail.com","name":"petrero"},"message":"  You now know that the proxy pre-fetches as expected, but does it deliver thepre-fetched profiles as it should?\n  Of course it doesn’t! You haven’t coded that part yet! Resisting the urge to produce useful code for the application, you code a test first\n  Anticipating further tests, you have placed the prefetchLimit and proxyInstance variables in a scope that will be accessible to both the new test and future tests. The proxyInstance is initialized afresh for each test in a beforeEach .\n  In the test, you call getProfile on the proxy. You expect to get the return value from the underlying attendeeProfileService . But what is the strange makeServiceReturn call? Like the Decorator Pattern (see Chapter 12), the Proxy Pattern delegates the real work to its subject. It should not concern itself with one iota more of the subject’s semantics than necessary. In the present case, the attendeeProfileProxy has no reason to care whether the underlying service is returning Promise s, JSON objects, or anything else. Therefore, the tests need not and should not care, either. This is why the makeServiceReturn function, defined near the top of describe block, makes a return value that is intentionally silly. The spy on the profile service, initialized in the first beforeEach , has been modified to return the fake value.\n  In spite of doing all that work, you are delighted when the test fails\n  Jasmine is telling you that your test’s call to getProfile took place on an object whose value is undefined , which would be proxyInstance . That’s no surprise. Until now, Conference .attendeeProfileProxy has not returned any value","distinct":true,"url":"https://api.github.com/repos/pyterDiaconescu/ReliableJavascript/commits/26c727292e4c0c62eac325034c12bfd2393c0aba"}]}