title: How can I unit test Knockout.js subscribe functions with Jasmine?
body: <p>I have a knockout viewmodel which has a few subscribe functions that update some default selections after it picks up a change to a parent selection.</p>
  
  <p>But I'm not sure how to call the function and fake the dependencies in order to test it. </p>
  
  <p>This code snippit is similar to the function but not the exact one. It's subscribed to SelectedParentOption observable and when it changes to checks through what's available and selects a new value. </p>
  
  <pre><code>        //When selection changes select default for remaining selection
          self.ServerModel.ProductModel.SelectedParentOption.subscribe(function () {
              // Loop through options returned by function checking for correct key
              self.availableOptions().forEach(function (option) {
                  if (option.Key == 1)
                      // Assign default selection
                      self.ServerModel.ProductModel.SelectedChildOption(option);
              }
          });
  </code></pre>
  
  <p>This is the Jasmine unit test</p>
  
  <pre><code>        it("Selection set to default after change", function () {
          // Spy on available options to dictate what's available
          spyOn(testModel, 'availableOptions').and.returnValue(TestOptions);
          // Change selection
          ServerModel.ProductModel.SelectedParentOption(Option1);
          // Call function
          ServerModel.ProductModel.SelectedParentOption.subscribe();
          // Verify default was selected
          expect(ServerModel.ProductModel.SelectedChildOption()).toBe(ExpectedOption);
      });
  </code></pre>
  
  <p>Currently this changes the option but the subscribe code doesn't seem to get hit at all. </p>