adobe/brackets — pull request #1008 by joelrbrandt (2012-06-07 05:51:45+00:00)
Title: Fix unit tests for JavaScriptInlineEditor

@redmunds

This fixes the two broken unit tests for the JavaScriptInlineEditor. The problem with the unit tests was that they weren't using the JSUtils that had been loaded by the extension. Instead, they were using a different JSUtils loaded in the same require context that loaded SpecRunner (i.e. the wrong window).

This worked for some unit tests because they were just testing "independent" functionality of JSUtils. However, JSUtils reaches in to the DocumentManager in some tests. Thus, these tests were failing because they were getting the wrong DocumentManager inside the JSUtils code (even though the unit test code was accessing the correct DocumentManager).

I added code to the ExtensionLoader that allows us to retrieve require contexts for extensions using the name of the extension. (This is the first commit).

Then, I modified the unit tests to request the JSUtils module from the extension's context. This fixed the unit tests. (This is the second commit).

There were also a few bugs in one of the unit tests. I fixed those too.

We should think about re-architecting how we run unit tests. It might make sense for each test window to import (a modified) SpecRunner and then load a particular test spec and run it. Then, the modified SpecRunner could report the results back to the main test window. This would potentially make it much simpler to write unit tests because they could simply use the global 'brackets' object to get at the modules they needed.