From 37152681345f49c0e9cb50dcdba65821f7937182 Mon Sep 17 00:00:00 2001 From: anuveyatsu Date: Fri, 12 Jun 2020 14:47:38 +0600 Subject: [PATCH] [mocks][m]: more detailed mocks with specific query param. --- mocks/index.js | 58 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/mocks/index.js b/mocks/index.js index bc60b26a..95160f0f 100644 --- a/mocks/index.js +++ b/mocks/index.js @@ -6,8 +6,10 @@ module.exports.initMocks = function() { // "package_search" mocks - nock('http://mock.ckan/api/3/action') - .get('/package_search') + nock('http://mock.ckan/api/3/action', {'encodedQueryParams':true}) + .persist() + // 1. Call without query. + .get('/package_search?facet.field=organization&facet.field=groups&facet.field=tags&facet.field=res_format&facet.field=license_id&facet.limit=5') .reply(200, { "success": true, "result": { @@ -16,10 +18,58 @@ module.exports.initMocks = function() { "facets": {}, "results": [ { - "name": "gdp" + "name": "gdp", + "title": "Country, Regional and World GDP (Gross Domestic Product)", + "notes": "Country, regional and world GDP in current US Dollars ($). Regional means collections of countries e.g. Europe & Central Asia. Data is sourced from the World Bank and turned into a standard normalized CSV.", + "resources": [ + { + "name": "gdp" + } + ], + "organization": { + "title": "World Bank", + "name": "world-bank", + } }, { - "name": "population" + "name": "population", + "title": "World population data", + "resources": [ + { + "name": "population" + } + ], + "organization": { + "title": "World Bank", + "name": "world-bank", + } + } + ], + "search_facets": {} + } + }) + // 2. Call with `q=gdp` query. + .get('/package_search?q=gdp&facet.field=organization&facet.field=groups&facet.field=tags&facet.field=res_format&facet.field=license_id&facet.limit=5') + .reply(200, { + "success": true, + "result": { + "count": 1, + "sort": "score desc, metadata_modified desc", + "facets": {}, + "results": [ + { + "name": "gdp", + "title": "Country, Regional and World GDP (Gross Domestic Product)", + "notes": "Country, regional and world GDP in current US Dollars ($). Regional means collections of countries e.g. Europe & Central Asia. Data is sourced from the World Bank and turned into a standard normalized CSV.", + "resources": [ + { + "name": "gdp" + } + ], + "organization": { + "title": "World Bank", + "name": "world-bank", + } } ], "search_facets": {}