A simple trick to make your classes easier to test
Luís Costa
142

I generally dislike dependency inject used as a way to get around de-coupling. AngularJS certainly uses it well, but for this case I actually think using closures would not only make it easier to test, but also make the resolver class and the fetcher class not know anything about each other.

This allows the data fetching class, and the consumer class to not know anything, and their communication is restricted to a closure. It also makes it easy to add spies inside the closure to test the resolver.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.