diff -r 5e877acd85ca -r a10198c95808 unittests/tests/JSONSerializer.js --- a/unittests/tests/JSONSerializer.js Wed Oct 26 12:40:24 2011 +0200 +++ b/unittests/tests/JSONSerializer.js Wed Oct 26 12:41:14 2011 +0200 @@ -98,4 +98,34 @@ }); + + test("test occurence count", function() { + var ser = new IriSP.JSONSerializer(this.dt, "../test/test.json"); + + ser._data = { annotations : [ + {"content": { + "description": "professeur", + "title": "garrigou" + }, "id" : 1 }, + { "content": { + "description": "interview", + "title": "Revue de presse - Hervé Gardette" + }, "id" : 2}, + {"content": { + "description": "concept", + "title": "idée" + }, "id" : 3}, + { "content": { + "description": "", + "title": "sans titre" + }, "id" : 4} + ]}; + + // warning : these tests may not work with ie8, safari 4, etc. + equal(Object.keys(ser.searchOccurences("garrigou")).length, 1, "first request works"); + deepEqual(ser.searchOccurences("garrigou"), {1 : 1}, "returned object is correctly defined"); + + equal(Object.keys(ser.searchOccurences("garrigou interview")).length, 2, "second request works"); + equal(Object.keys(ser.searchOccurences("garrigou idée interview")).length, 3, "third request works"); + }); }; \ No newline at end of file