unittests/tests/JSONSerializer.js
branchpopcorn-port
changeset 149 a10198c95808
parent 147 955119f901b4
child 156 0e6a4d1e4dbe
equal deleted inserted replaced
148:5e877acd85ca 149:a10198c95808
    96       equal(ser.searchAnnotations("", "", "").length, 4, "empty request works");
    96       equal(ser.searchAnnotations("", "", "").length, 4, "empty request works");
    97       equal(ser.searchAnnotations("idée", "concept", "").length, 1, "specific request works");
    97       equal(ser.searchAnnotations("idée", "concept", "").length, 1, "specific request works");
    98       
    98       
    99       
    99       
   100     });
   100     });
       
   101     
       
   102     test("test occurence count", function() {
       
   103     var ser = new IriSP.JSONSerializer(this.dt, "../test/test.json");
       
   104             
       
   105       ser._data = { annotations : [
       
   106       {"content": {        
       
   107         "description": "professeur", 
       
   108         "title": "garrigou"
       
   109         }, "id" : 1 },
       
   110       { "content": {        
       
   111         "description": "interview", 
       
   112         "title": "Revue de presse - Hervé Gardette"
       
   113       }, "id" : 2},
       
   114       {"content": {        
       
   115         "description": "concept", 
       
   116         "title": "idée"
       
   117       }, "id" : 3},
       
   118       { "content": {        
       
   119         "description": "", 
       
   120         "title": "sans titre"
       
   121       }, "id" : 4}
       
   122       ]};
       
   123             
       
   124       // warning : these tests may not work with ie8, safari 4, etc.      
       
   125       equal(Object.keys(ser.searchOccurences("garrigou")).length, 1, "first request works");
       
   126       deepEqual(ser.searchOccurences("garrigou"), {1 : 1}, "returned object is correctly defined");
       
   127       
       
   128       equal(Object.keys(ser.searchOccurences("garrigou interview")).length, 2, "second request works");
       
   129       equal(Object.keys(ser.searchOccurences("garrigou idée interview")).length, 3, "third request works");
       
   130     });
   101 };
   131 };