unittests/tests/serializers/JSONSerializer.js
author hamidouk
Mon, 19 Dec 2011 15:25:22 +0100
branchpopcorn-port
changeset 481 a46cfeee6d77
parent 320 b693ba1a83be
permissions -rw-r--r--
using jquery ui draggable changes the state of an element from absolute to relative positioning, which breaks the way our seek button expands itself, so we need to force absolute positioning, quite uglily, using jquery.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
234
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
     1
function test_JSONSerializer() {
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
     2
  module("JSON Serializer tests", 
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
     3
    { setup: function() {      
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
     4
      this.dt = new IriSP.DataLoader();
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
     5
      }
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
     6
    }
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
     7
    );    
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
     8
    
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
     9
    test("should return the correct JSON", function() {
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    10
      var arr = ["ab", {"de" : "fg"}, "lp"];
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    11
      var serializer = new IriSP.JSONSerializer(this.dt);
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    12
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    13
      equal(serializer.serialize(arr), JSON.stringify(arr), "assert that the outputted json is correct");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    14
    });
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    15
    
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    16
    test("sync()", function() {
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    17
      this.xhr = this.sandbox.useFakeXMLHttpRequest();
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    18
      this.requests = [];
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    19
      this.xhr.onCreate = function (request) {
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    20
        this.requests.push(request);
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    21
      };
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    22
      
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    23
      var response_array = { media: 12, content: "Hey there", 
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    24
                             annotations: [{"begin": "32", "end" : 64}, {"begin": "08", "end" : 27},{"begin": "02", "end" : 61}]  };
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    25
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    26
      /* sorted array is our comparision array */
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    27
      var sorted_array = IriSP.jQuery.extend({}, response_array);
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    28
      sorted_array.annotations.sort(function(a, b) 
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    29
          { var a_begin = +a.begin;
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    30
            var b_begin = +b.begin;
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    31
            return a_begin - b_begin;
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    32
          });
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    33
          
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    34
      var response_string = JSON.stringify(response_array);
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    35
  
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    36
      var spy_callback = this.spy();
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    37
      var ser = new IriSP.JSONSerializer(this.dt, "/url");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    38
      
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    39
      ser.sync(spy_callback);
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    40
      
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    41
      equals(this.xhr.requests.length, 1, "the mock ajax object should have received the request");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    42
      equals(this.xhr.requests[0].url, "/url", "the requested url is correct");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    43
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    44
      this.xhr.requests[0].respond(200, { "Content-Type": "application/json" },
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    45
                             response_string);
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    46
        
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    47
      ok(spy_callback.calledOnce, "callback called");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    48
      ok(spy_callback.calledWith(response_array), "callback called with correct value");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    49
      deepEqual(ser._data, response_array, "the internal variable is initialized to the correct value");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    50
      
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    51
      var order_preserved = true;
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    52
      
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    53
      var i = 0;
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    54
      for(i = 0; i < ser._data.length - 1; i++) {
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    55
        if (ser._data.annotations[i].begin > ser._data.annotations[i+1].begin) {
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    56
            order_preserved = false;
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    57
            break;
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    58
        }
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    59
      }
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    60
      
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    61
      ok(order_preserved, "the annotation sub-array is sorted by begin time");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    62
    });
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    63
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    64
    test("currentMedia should return the current media", function() {
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    65
      var ser = new IriSP.JSONSerializer(this.dt, "/url");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    66
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    67
      ser._data = {}
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    68
      ser._data.medias = [0];
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    69
      equal(ser.currentMedia(), 0, "currentMedia() returns the correct value");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    70
    });
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    71
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    72
    test("test annotation search", function() {
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    73
      var ser = new IriSP.JSONSerializer(this.dt, "../test/test.json");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    74
            
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    75
      ser._data = { annotations : [
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    76
      {"content": {        
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    77
        "description": "professeur", 
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    78
        "title": "garrigou"
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    79
        }},
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    80
      { "content": {        
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    81
        "description": "interview", 
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    82
        "title": "Revue de presse - Herv� Gardette"
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    83
      }},
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    84
      {"content": {        
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    85
        "description": "concept", 
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    86
        "title": "id�e"
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    87
      }},
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    88
      { "content": {        
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    89
        "description": "", 
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    90
        "title": "sans titre"
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    91
      }}
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    92
      ]};
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    93
      
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    94
      equal(ser.searchAnnotations("GarriGOU", "", "").length, 1, "requesting on title works");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    95
      equal(ser.searchAnnotations("", "IntErView", "").length, 1, "requesting on description works");      
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    96
      equal(ser.searchAnnotations("", "", "").length, 4, "empty request works");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    97
      equal(ser.searchAnnotations("id�e", "concept", "").length, 1, "specific request works");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    98
      
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
    99
      
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   100
    });
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   101
    
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   102
    test("test occurence count", function() {
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   103
    var ser = new IriSP.JSONSerializer(this.dt, "../test/test.json");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   104
            
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   105
      ser._data = { annotations : [
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   106
      {"content": {        
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   107
        "description": "professeur", 
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   108
        "title": "garrigou"
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   109
        }, "id" : 1 },
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   110
      { "content": {        
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   111
        "description": "interview", 
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   112
        "title": "Revue de presse - Herv� Gardette"
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   113
      }, "id" : 2},
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   114
      {"content": {        
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   115
        "description": "concept", 
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   116
        "title": "id�e"
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   117
      }, "id" : 3},
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   118
      { "content": {        
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   119
        "description": "", 
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   120
        "title": "sans titre"
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   121
      }, "id" : 4}
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   122
      ]};
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   123
      
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   124
      // a function to get the number of fields in a dict.
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   125
      function countOccurences(queryString) {
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   126
        var count = 0;
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   127
        for (var i in ser.searchOccurences(queryString)) {
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   128
          count++;
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   129
        };
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   130
        
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   131
        return count;
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   132
      };
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   133
      
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   134
      equal(countOccurences("garrigou"), 1, "first request works");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   135
      deepEqual(ser.searchOccurences("garrigou"), {1 : 1}, "returned object is correctly defined");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   136
          
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   137
      equal(countOccurences("garrigou interview"), 2, "second request works");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   138
      equal(countOccurences("garrigou id�e interview"), 3, "third request works");
43b198dc932d reorganized the layout of the test directories to follow the layout the source
hamidouk
parents:
diff changeset
   139
    });
317
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   140
    
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   141
    test("test current annotation search", function() {
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   142
      var ser = new IriSP.JSONSerializer(this.dt, "../test/test.json");      
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   143
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   144
      ser._data = { 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   145
      "views": [
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   146
          {
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   147
            "id": "0", 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   148
            "contents": [
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   149
              "franceculture_retourdudimanche20100620"
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   150
            ], 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   151
            "annotation_types": [
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   152
              "c_1F07824B-F512-78A9-49DB-6FB51DAB9560"
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   153
            ]
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   154
          }
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   155
        ], 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   156
          annotations : [
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   157
      {"begin": 1234, "end" : 578900,
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   158
       "content": {        
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   159
        "description": "professeur", 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   160
        "title": "garrigou"
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   161
        }, 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   162
      "id" : 1,
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   163
      "meta": {
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   164
        "dc:contributor": "perso", 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   165
        "id-ref": "c_1F07824B-F512-78A9-49DB-6FB51DAB9560", 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   166
        "dc:created": "2011-10-20T13:36:18.286693", 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   167
        "dc:modified": "2011-10-20T13:36:18.286693", 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   168
        "dc:creator": "perso"
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   169
        } 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   170
      }, 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   171
      {"begin": 1234, "end" : 578900,
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   172
       "content": {        
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   173
        "description": "interview", 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   174
        "title": "Revue de presse - Herv� Gardette"
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   175
        }, 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   176
       "id" : 2, 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   177
       "meta": {
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   178
        "dc:contributor": "perso", 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   179
        "id-ref": "c_1F07824B-F512-78A9-49DB-6FB51DAB9560", 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   180
        "dc:created": "2011-10-20T13:36:18.286693", 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   181
        "dc:modified": "2011-10-20T13:36:18.286693", 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   182
        "dc:creator": "perso"
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   183
        } 
320
b693ba1a83be fixed bug in search method
hamidouk
parents: 317
diff changeset
   184
      },
b693ba1a83be fixed bug in search method
hamidouk
parents: 317
diff changeset
   185
      {"begin": 1234, "end" : 578900,
b693ba1a83be fixed bug in search method
hamidouk
parents: 317
diff changeset
   186
       "content": {        
b693ba1a83be fixed bug in search method
hamidouk
parents: 317
diff changeset
   187
        "description": "interview", 
b693ba1a83be fixed bug in search method
hamidouk
parents: 317
diff changeset
   188
        "title": "lolol"
b693ba1a83be fixed bug in search method
hamidouk
parents: 317
diff changeset
   189
        }, 
b693ba1a83be fixed bug in search method
hamidouk
parents: 317
diff changeset
   190
       "id" : 2, 
b693ba1a83be fixed bug in search method
hamidouk
parents: 317
diff changeset
   191
       "meta": {
b693ba1a83be fixed bug in search method
hamidouk
parents: 317
diff changeset
   192
        "dc:contributor": "perso", 
b693ba1a83be fixed bug in search method
hamidouk
parents: 317
diff changeset
   193
        "id-ref": "c_dfdfdfdf", 
b693ba1a83be fixed bug in search method
hamidouk
parents: 317
diff changeset
   194
        "dc:created": "2011-10-20T13:36:18.286693", 
b693ba1a83be fixed bug in search method
hamidouk
parents: 317
diff changeset
   195
        "dc:modified": "2011-10-20T13:36:18.286693", 
b693ba1a83be fixed bug in search method
hamidouk
parents: 317
diff changeset
   196
        "dc:creator": "perso"
b693ba1a83be fixed bug in search method
hamidouk
parents: 317
diff changeset
   197
        } 
317
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   198
      }
320
b693ba1a83be fixed bug in search method
hamidouk
parents: 317
diff changeset
   199
 
317
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   200
      ]};
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   201
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   202
      var ret = ser.currentAnnotations(234);  
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   203
      equal(ret.length, 2, "the correct number of elements is returned");
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   204
      ok(ret[0].begin < 234 * 1000 && ret[0].end > 234 * 1000 && 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   205
         ret[0].meta["id-ref"] == "c_1F07824B-F512-78A9-49DB-6FB51DAB9560",
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   206
         "the first element is correctly configured");
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   207
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   208
    });
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   209
 
a3492448fa9a begun the implementation of annotation search according to a timecode.
hamidouk
parents: 234
diff changeset
   210
};