MarionetteLabs/marionette.inspector — pull request #35 by jasonLaster (2014-10-31 19:45:13+00:00)
Title: Add the cat

So, I have to start with a confession... working on the inspector is taxing. This is mostly because manually testing the different parts is pretty time consuming and it's hard to follow when something breaks. With that in mind, I sat down to take a stab at adding some unit tests.

There are three parts of the Inspector we could test:
1. agent
2. communication layer
3. inspector

I chose to just focus on the agent today. And actually only a part of the agent. Of the three parts of the agent:
1. appObserver
2. detecting marionette, backbone
3. patching the app.

I chose to only test the third part. patching the app. Why? Well, if we had to detect Marionette and Backbone each time we ran a test, it'd be a headache. And the appObserver stuff is for another day :)

So, what are the implementation details:

1. I brought over the same testing tools from marionette proper (mocha, sinon, chai) all that jazz

2. I split agent.js into core.js and agent.js. The core component doesn't attempt to detect marionette and backbone. It just patches the two libs and starts from there. I changed `onModulesDetected` to `patchBackboneMarionette` to signal the change in intent. I also changed `windowBackbone` to `patchedBackbone` to signal the new intent.

3. I started writing some tests. They were fun. I realize this should have been done last night at MHH :P

![](http://f.cl.ly/items/2c1r2q0C34332d2d1c1W/Image%202014-10-31%20at%203.31.30%20PM.png)