unittests/tests/serializerFactory.js
author hamidouk
Thu, 20 Oct 2011 15:50:04 +0200
branchpopcorn-port
changeset 103 2dfd89e91c3a
parent 65 6a8cae20f190
child 128 f3fec80dd31c
permissions -rw-r--r--
added a method to sort the json annotations. changed the tests accordingly.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
65
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
     1
/* tests for the serializer factory */
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
     2
function test_serializerFactory() {
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
     3
  module("SerializerFactory tests", 
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
     4
    { setup: function() {
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
     5
              this.dt = new IriSP.DataLoader();
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
     6
  }}); 
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
     7
  
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
     8
  test("test instantiation of a json serializer", function() {
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
     9
    var factory = new IriSP.SerializerFactory(this.dt);    
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
    10
    var config = {metadata : { load: "json", src : "/url" } };
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
    11
    var ser = factory.getSerializer(config);
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
    12
    
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
    13
    ok(ser instanceof IriSP.JSONSerializer, "returned object is instance of json serializer");    
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
    14
  });
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
    15
  
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
    16
  test("test instantiation of a garbage serializer", function() {
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
    17
    var factory = new IriSP.SerializerFactory(this.dt);    
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
    18
    var config = {metadata : { load: "garbage", src : "/url" } };
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
    19
    var ser = factory.getSerializer(config);
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
    20
    
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
    21
    equal(ser, undefined, "returned object is undefined");    
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
    22
  });
6a8cae20f190 Added new unit tests and changes to the data classes.
hamidouk
parents:
diff changeset
    23
};