[#217,backend/ckan][s]: support for sorting (plus refactor to have a normalizeQuery method).

This commit is contained in:
Rufus Pollock
2012-08-22 09:51:33 +01:00
parent fe41a0cf90
commit e2963e9fb7
2 changed files with 41 additions and 4 deletions

View File

@@ -1,6 +1,31 @@
(function ($) {
module("Backend CKAN");
test('_normalizeQuery', function() {
var dataset = new recline.Model.Dataset({
url: 'does-not-matter',
id: 'xyz',
backend: 'ckan'
});
var queryObj = {
q: 'abc',
sort: [
{ field: 'location', order: 'desc' },
{ field: 'last' }
]
};
var out = recline.Backend.Ckan._normalizeQuery(queryObj, dataset);
var exp = {
resource_id: dataset.id,
q: 'abc',
sort: 'location desc,last ',
limit: 10,
offset: 0
};
deepEqual(out, exp);
});
test("fetch", function() {
var dataset = new recline.Model.Dataset({
url: 'http://localhost:5000/dataset/test-data-viewer/resource/4f1299ab-a100-4e5f-ba81-e6d234a2f3bd',