Ember has an amazing testing story built upon the fundamentals of encapsulation and OO programming central to the framework. Despite this, every web application will be dependent upon and need to interact with native and network APIs that are hostile: Unreliable, slow, under-documented, and not to be trusted. The challenge in testing Ember applications lies with how to handle these external entities.
7. A conference planning app
• Submitting a talk
• Purchasing a ticket
• Preparing a talk
8. • Submitting a talk
• Purchasing a ticket
• Preparing a talk
The domain
A conference planning app
9. A conference planning app
• Submitting a talk
• Purchasing a ticket
• Preparing a talk
10. A conference planning app
• Adapting to a server
• Managing asynchronous APIs
• Browser APIs
• Submitting a talk
• Purchasing a ticket
• Preparing a talk
ᗜੂͦ﹏ᗜੂͦ
11. A conference planning app
• Adapting to a server
• Managing asynchronous APIs
• Browser APIs
• Submitting a talk
• Purchasing a ticket
• Preparing a talk
The domain
12. A conference planning app What is this?!
• Adapting to a server
• Managing asynchronous APIs
• Browser APIs
• Submitting a talk
• Purchasing a ticket
• Preparing a talk
ᗜੂͦ﹏ᗜੂͦ
55. Dependency Lookup
1 var Gadget = Ember.Object.create({!
2 shelf: function(){!
3 return Shelf.create();!
4 }!
5 });!
6 !
7 Gadget.create();!
Dependency Injection / Inversion of Control
1 var Gadget = Ember.Object.create({!
2 });!
3 !
4 function buildGadget(){!
5 return Gadget.create({!
6 shelf: Shelf.create()!
7 });!
8 }!
56. Converting “Dependency Lookup” to
“Dependency Injection”
1. Create an initializer
2. Register the dependency
3. Inject the dependency
4. Drop the lookup