title: Unit Testing Knockout Binding Handlers with Jasmine
body: <p>I have created a binding handler dependent on moment which is used for formatting the date. I wanted to unit test this binding handler using Jasmine. </p>
  
  <p>Below is my binding handler code:</p>
  
  <pre><code>define(['knockout', 'moment'], function (ko, moment) {
  
      'use strict';
      ko.bindingHandlers.date = {
          update: function (element, dateValue, allBindings) {
              var date = ko.utils.unwrapObservable(dateValue()) || '-',
                  format = allBindings.get('format'),
                  formattedDate = function () {
                      return moment(date).format(format);
                  };
              ko.bindingHandlers.text.update(element, formattedDate);
          }
      };
  
      return {
          dateBinding: ko.bindingHandlers.date
      };
  });
  </code></pre>
  
  <p>I am creating my spec file as below:</p>
  
  <pre><code>define(['testUtils', 'jquery', 'knockout'], function (testUtils, $, ko) {
  
      'use strict';
      ddescribe('utils/date.binding', function () {
  
          var testee;
  
          beforeEach(function (done) {
              testUtils.loadWithCurrentStubs('utils/date.binding', function (dateUtils) {
                  testee = dateUtils;
                  done();
              });
          });
  
          afterEach(function () {
              testUtils.reset();
          });
  
          describe('ko.bindingHandlers.date', function () {
              var element = document.createElement();
  
              it('should be true', function () {
                  expect(true).toBe(true);
              });
          });
      });
  });
  </code></pre>
  
  <p>Not sure where to start testing and what parts needs to be tested.</p>