unittests/tests/serializers/mockSerializer.js
author hamidouk
Mon, 14 Nov 2011 12:26:17 +0100
branchpopcorn-port
changeset 234 43b198dc932d
permissions -rw-r--r--
reorganized the layout of the test directories to follow the layout the source code.

function test_mockSerializer() {
  module("Mock Serializer basic tests");
  
  test("init the serializer with a DataLoader and an url", function() {
      var dt = new IriSP.DataLoader();
      var ser = new IriSP.MockSerializer(dt, "http://google.com");
      equal( ser._DataLoader, dt, "The dataloader reference is copied to the object." );
      equal( ser._url, "http://google.com", "The url has been copied as well." );
      ok(ser._data, "the mock data is defined");
  });
  
  test("check that the serialize and deserialize abstract functions are defined", function() {
      var dt = new IriSP.DataLoader();
      var ser = new IriSP.MockSerializer(dt);
      notEqual(ser.serialize, undefined, ".serialize is defined");
      notEqual(ser.deserialize, undefined, ".deserialize is defined");
  });
  
  test("check that the callback is called", function() {
      var dt = new IriSP.DataLoader();
      var ser = new IriSP.MockSerializer(dt);
      var spy = this.spy();
      ser.sync(spy);
      ok(spy.called, "the callback has been called");
  });

};