Add spec
This commit is contained in:
parent
02ac25181e
commit
1664975dd1
@ -78,10 +78,11 @@ describe('analysis-filters-params', () => {
|
|||||||
|
|
||||||
it('should get a filtered histogram dataview with all filters', function(done) {
|
it('should get a filtered histogram dataview with all filters', function(done) {
|
||||||
const testClient = new TestClient(mapConfig, 1234);
|
const testClient = new TestClient(mapConfig, 1234);
|
||||||
|
const testParams = Object.assign({}, params, {
|
||||||
|
own_filter: 1
|
||||||
|
});
|
||||||
|
|
||||||
params.own_filter = 1;
|
testClient.getDataview('pop_max_histogram', testParams, (err, dataview) => {
|
||||||
|
|
||||||
testClient.getDataview('pop_max_histogram', params, (err, dataview) => {
|
|
||||||
assert.ok(!err, err);
|
assert.ok(!err, err);
|
||||||
|
|
||||||
assert.equal(dataview.type, 'histogram');
|
assert.equal(dataview.type, 'histogram');
|
||||||
@ -93,10 +94,11 @@ describe('analysis-filters-params', () => {
|
|||||||
|
|
||||||
it('should get a filtered histogram dataview with all filters except my own filter', function(done) {
|
it('should get a filtered histogram dataview with all filters except my own filter', function(done) {
|
||||||
const testClient = new TestClient(mapConfig, 1234);
|
const testClient = new TestClient(mapConfig, 1234);
|
||||||
|
const testParams = Object.assign({}, params, {
|
||||||
|
own_filter: 0
|
||||||
|
});
|
||||||
|
|
||||||
params.own_filter = 0;
|
testClient.getDataview('pop_max_histogram', testParams, (err, dataview) => {
|
||||||
|
|
||||||
testClient.getDataview('pop_max_histogram', params, (err, dataview) => {
|
|
||||||
assert.ok(!err, err);
|
assert.ok(!err, err);
|
||||||
|
|
||||||
assert.equal(dataview.type, 'histogram');
|
assert.equal(dataview.type, 'histogram');
|
||||||
@ -108,10 +110,11 @@ describe('analysis-filters-params', () => {
|
|||||||
|
|
||||||
it('should get a filtered histogram dataview without filters', function(done) {
|
it('should get a filtered histogram dataview without filters', function(done) {
|
||||||
const testClient = new TestClient(mapConfig, 1234);
|
const testClient = new TestClient(mapConfig, 1234);
|
||||||
|
const testParams = Object.assign({}, params, {
|
||||||
|
no_filters: 1
|
||||||
|
});
|
||||||
|
|
||||||
params.no_filters = 1;
|
testClient.getDataview('pop_max_histogram', testParams, (err, dataview) => {
|
||||||
|
|
||||||
testClient.getDataview('pop_max_histogram', params, (err, dataview) => {
|
|
||||||
assert.ok(!err, err);
|
assert.ok(!err, err);
|
||||||
|
|
||||||
assert.equal(dataview.type, 'histogram');
|
assert.equal(dataview.type, 'histogram');
|
||||||
@ -121,4 +124,27 @@ describe('analysis-filters-params', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return an error if both no_filters and own_filter params are present', function (done) {
|
||||||
|
const testClient = new TestClient(mapConfig, 1234);
|
||||||
|
const expectedError = {
|
||||||
|
errors: ['Both own_filter and no_filters cannot be sent in the same request'],
|
||||||
|
errors_with_context: [{
|
||||||
|
type: 'dataview',
|
||||||
|
message: 'Both own_filter and no_filters cannot be sent in the same request'
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
const testParams = Object.assign({}, params, {
|
||||||
|
no_filters: 1,
|
||||||
|
own_filter: 0,
|
||||||
|
response: {
|
||||||
|
status: 400
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
testClient.getDataview('pop_max_histogram', testParams, (err, dataview) => {
|
||||||
|
assert.deepEqual(dataview, expectedError);
|
||||||
|
|
||||||
|
testClient.drain(done);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -109,7 +109,8 @@ describe('analysis-layers-dataviews', function() {
|
|||||||
min: 2e6
|
min: 2e6
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
own_filter: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
testClient.getDataview('pop_max_histogram', params, function(err, dataview) {
|
testClient.getDataview('pop_max_histogram', params, function(err, dataview) {
|
||||||
|
@ -393,7 +393,8 @@ describe('dataviews using tables with overviews', function() {
|
|||||||
var params = {
|
var params = {
|
||||||
filters: {
|
filters: {
|
||||||
dataviews: { test_histogram: { min: 2 } }
|
dataviews: { test_histogram: { min: 2 } }
|
||||||
}
|
},
|
||||||
|
own_filter: 1
|
||||||
};
|
};
|
||||||
var testClient = new TestClient(overviewsMapConfig);
|
var testClient = new TestClient(overviewsMapConfig);
|
||||||
testClient.getDataview('test_histogram', params, function (err, histogram) {
|
testClient.getDataview('test_histogram', params, function (err, histogram) {
|
||||||
@ -412,7 +413,8 @@ describe('dataviews using tables with overviews', function() {
|
|||||||
var params = {
|
var params = {
|
||||||
filters: {
|
filters: {
|
||||||
dataviews: { test_histogram: { max: -1 } }
|
dataviews: { test_histogram: { max: -1 } }
|
||||||
}
|
},
|
||||||
|
own_filter: 1
|
||||||
};
|
};
|
||||||
var testClient = new TestClient(overviewsMapConfig);
|
var testClient = new TestClient(overviewsMapConfig);
|
||||||
testClient.getDataview('test_histogram', params, function (err, histogram) {
|
testClient.getDataview('test_histogram', params, function (err, histogram) {
|
||||||
@ -433,7 +435,8 @@ describe('dataviews using tables with overviews', function() {
|
|||||||
var params = {
|
var params = {
|
||||||
filters: {
|
filters: {
|
||||||
dataviews: { test_histogram_date: { max: -1 } }
|
dataviews: { test_histogram_date: { max: -1 } }
|
||||||
}
|
},
|
||||||
|
own_filter: 1
|
||||||
};
|
};
|
||||||
var testClient = new TestClient(overviewsMapConfig);
|
var testClient = new TestClient(overviewsMapConfig);
|
||||||
testClient.getDataview('test_histogram_date', params, function (err, histogram) {
|
testClient.getDataview('test_histogram_date', params, function (err, histogram) {
|
||||||
|
@ -414,8 +414,9 @@ TestClient.prototype.getDataview = function(dataviewName, params, callback) {
|
|||||||
var urlParams = {};
|
var urlParams = {};
|
||||||
if (params.hasOwnProperty('no_filters')) {
|
if (params.hasOwnProperty('no_filters')) {
|
||||||
urlParams.no_filters = params.no_filters;
|
urlParams.no_filters = params.no_filters;
|
||||||
} else {
|
}
|
||||||
urlParams.own_filter = params.hasOwnProperty('own_filter') ? params.own_filter : 1;
|
if (params.hasOwnProperty('own_filter')) {
|
||||||
|
urlParams.own_filter = params.own_filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
['bbox', 'bins', 'start', 'end', 'aggregation', 'offset', 'categories'].forEach(function(extraParam) {
|
['bbox', 'bins', 'start', 'end', 'aggregation', 'offset', 'categories'].forEach(function(extraParam) {
|
||||||
|
Loading…
Reference in New Issue
Block a user