Test names and instanceof checks
This commit is contained in:
@@ -4,9 +4,9 @@ describe('ol.parser.ogc.Filter_v1_0_0', function() {
|
|||||||
|
|
||||||
var parser = new ol.parser.ogc.Filter_v1_0_0();
|
var parser = new ol.parser.ogc.Filter_v1_0_0();
|
||||||
|
|
||||||
describe('#readwrite', function() {
|
describe('reading and writing', function() {
|
||||||
|
|
||||||
it('intersects filter read / written correctly', function(done) {
|
it('handles intersects', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/intersects.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/intersects.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var filter = parser.read(xml);
|
var filter = parser.read(xml);
|
||||||
@@ -23,7 +23,7 @@ describe('ol.parser.ogc.Filter_v1_0_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('within filter read / written correctly', function(done) {
|
it('handles within', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/within.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/within.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var filter = parser.read(xml);
|
var filter = parser.read(xml);
|
||||||
@@ -39,7 +39,7 @@ describe('ol.parser.ogc.Filter_v1_0_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('contains filter read / written correctly', function(done) {
|
it('handles contains', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/contains.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/contains.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var filter = parser.read(xml);
|
var filter = parser.read(xml);
|
||||||
@@ -56,18 +56,18 @@ describe('ol.parser.ogc.Filter_v1_0_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('between filter read / written correctly', function(done) {
|
it('handles between', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/between.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/between.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var filter = parser.read(xml);
|
var filter = parser.read(xml);
|
||||||
expect(filter instanceof ol.expr.Logical).to.be.ok();
|
expect(filter).to.be.a(ol.expr.Logical);
|
||||||
expect(filter.getOperator()).to.equal(ol.expr.LogicalOp.AND);
|
expect(filter.getOperator()).to.equal(ol.expr.LogicalOp.AND);
|
||||||
expect(filter.getLeft() instanceof ol.expr.Comparison).to.be.ok();
|
expect(filter.getLeft()).to.be.a(ol.expr.Comparison);
|
||||||
expect(filter.getLeft().getOperator()).to.equal(
|
expect(filter.getLeft().getOperator()).to.equal(
|
||||||
ol.expr.ComparisonOp.GTE);
|
ol.expr.ComparisonOp.GTE);
|
||||||
expect(filter.getLeft().getLeft().getName()).to.equal('number');
|
expect(filter.getLeft().getLeft().getName()).to.equal('number');
|
||||||
expect(filter.getLeft().getRight().getValue()).to.equal(0);
|
expect(filter.getLeft().getRight().getValue()).to.equal(0);
|
||||||
expect(filter.getRight() instanceof ol.expr.Comparison).to.be.ok();
|
expect(filter.getRight()).to.be.a(ol.expr.Comparison);
|
||||||
expect(filter.getRight().getOperator()).to.equal(
|
expect(filter.getRight().getOperator()).to.equal(
|
||||||
ol.expr.ComparisonOp.LTE);
|
ol.expr.ComparisonOp.LTE);
|
||||||
expect(filter.getRight().getLeft().getName()).to.equal('number');
|
expect(filter.getRight().getLeft().getName()).to.equal('number');
|
||||||
@@ -78,18 +78,18 @@ describe('ol.parser.ogc.Filter_v1_0_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('between filter read correctly without literals', function(done) {
|
it('handles between without literals', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/between2.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/between2.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var filter = parser.read(xml);
|
var filter = parser.read(xml);
|
||||||
expect(filter instanceof ol.expr.Logical).to.be.ok();
|
expect(filter).to.be.a(ol.expr.Logical);
|
||||||
expect(filter.getOperator()).to.equal(ol.expr.LogicalOp.AND);
|
expect(filter.getOperator()).to.equal(ol.expr.LogicalOp.AND);
|
||||||
expect(filter.getLeft() instanceof ol.expr.Comparison).to.be.ok();
|
expect(filter.getLeft()).to.be.a(ol.expr.Comparison);
|
||||||
expect(filter.getLeft().getOperator()).to.equal(
|
expect(filter.getLeft().getOperator()).to.equal(
|
||||||
ol.expr.ComparisonOp.GTE);
|
ol.expr.ComparisonOp.GTE);
|
||||||
expect(filter.getLeft().getLeft().getName()).to.equal('number');
|
expect(filter.getLeft().getLeft().getName()).to.equal('number');
|
||||||
expect(filter.getLeft().getRight().getValue()).to.equal(0);
|
expect(filter.getLeft().getRight().getValue()).to.equal(0);
|
||||||
expect(filter.getRight() instanceof ol.expr.Comparison).to.be.ok();
|
expect(filter.getRight()).to.be.a(ol.expr.Comparison);
|
||||||
expect(filter.getRight().getOperator()).to.equal(
|
expect(filter.getRight().getOperator()).to.equal(
|
||||||
ol.expr.ComparisonOp.LTE);
|
ol.expr.ComparisonOp.LTE);
|
||||||
expect(filter.getRight().getLeft().getName()).to.equal('number');
|
expect(filter.getRight().getLeft().getName()).to.equal('number');
|
||||||
@@ -98,11 +98,11 @@ describe('ol.parser.ogc.Filter_v1_0_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('null filter read / written correctly', function(done) {
|
it('handles null', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/null.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/null.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var filter = parser.read(xml);
|
var filter = parser.read(xml);
|
||||||
expect(filter instanceof ol.expr.Comparison).to.be.ok();
|
expect(filter).to.be.a(ol.expr.Comparison);
|
||||||
expect(filter.getLeft().getName()).to.equal('prop');
|
expect(filter.getLeft().getName()).to.equal('prop');
|
||||||
expect(filter.getRight().getValue()).to.equal(null);
|
expect(filter.getRight().getValue()).to.equal(null);
|
||||||
var output = parser.write(filter);
|
var output = parser.write(filter);
|
||||||
@@ -111,7 +111,7 @@ describe('ol.parser.ogc.Filter_v1_0_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('BBOX written correctly', function(done) {
|
it('writes BBOX', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/bbox.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/bbox.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var filter = new ol.expr.Call(
|
var filter = new ol.expr.Call(
|
||||||
@@ -126,7 +126,7 @@ describe('ol.parser.ogc.Filter_v1_0_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('BBOX without geometry name written correctly', function(done) {
|
it('writes BBOX without geometry name', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/bbox_nogeom.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/bbox_nogeom.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var filter = new ol.expr.Call(
|
var filter = new ol.expr.Call(
|
||||||
@@ -161,7 +161,7 @@ describe('ol.parser.ogc.Filter_v1_0_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('DWithin written correctly', function(done) {
|
it('writes DWithin', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/dwithin.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/dwithin.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var filter = new ol.expr.Call(new ol.expr.Identifier(
|
var filter = new ol.expr.Call(new ol.expr.Identifier(
|
||||||
@@ -182,9 +182,9 @@ describe('ol.parser.ogc.Filter_v1_0_0', function() {
|
|||||||
|
|
||||||
// the Filter Encoding spec doesn't allow for FID filters inside logical
|
// the Filter Encoding spec doesn't allow for FID filters inside logical
|
||||||
// filters however, to be liberal, we will write them without complaining
|
// filters however, to be liberal, we will write them without complaining
|
||||||
describe('#logicalfid', function() {
|
describe('logical fid', function() {
|
||||||
|
|
||||||
it('logical filter [OR] with fid filter written correctly', function(done) {
|
it('writes logical [OR] with fid', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/logicalfeatureid.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/logicalfeatureid.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var filter = new ol.expr.Logical(ol.expr.LogicalOp.OR,
|
var filter = new ol.expr.Logical(ol.expr.LogicalOp.OR,
|
||||||
@@ -200,7 +200,7 @@ describe('ol.parser.ogc.Filter_v1_0_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('logical filter [AND] with fid filter written correctly',
|
it('writes logical [AND] with fid',
|
||||||
function(done) {
|
function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/' +
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/' +
|
||||||
'logicalfeatureidand.xml';
|
'logicalfeatureidand.xml';
|
||||||
@@ -218,7 +218,7 @@ describe('ol.parser.ogc.Filter_v1_0_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('logical filter [NOT] with fid filter written correctly',
|
it('writes logical [NOT] with fid',
|
||||||
function(done) {
|
function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/' +
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_0_0/' +
|
||||||
'logicalfeatureidnot.xml';
|
'logicalfeatureidnot.xml';
|
||||||
@@ -234,8 +234,8 @@ describe('ol.parser.ogc.Filter_v1_0_0', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('_expression reader works as expected', function() {
|
describe('_expression reader', function() {
|
||||||
it('_expression reader handles combined propertyname and literal',
|
it('handles combined propertyname and literal',
|
||||||
function() {
|
function() {
|
||||||
var xml = '<ogc:UpperBoundary xmlns:ogc="' +
|
var xml = '<ogc:UpperBoundary xmlns:ogc="' +
|
||||||
'http://www.opengis.net/ogc">10</ogc:UpperBoundary>';
|
'http://www.opengis.net/ogc">10</ogc:UpperBoundary>';
|
||||||
@@ -243,7 +243,7 @@ describe('ol.parser.ogc.Filter_v1_0_0', function() {
|
|||||||
'_expression'];
|
'_expression'];
|
||||||
var expr = reader.call(parser, goog.dom.xml.loadXml(
|
var expr = reader.call(parser, goog.dom.xml.loadXml(
|
||||||
xml).documentElement);
|
xml).documentElement);
|
||||||
expect(expr instanceof ol.expr.Literal).to.be.ok();
|
expect(expr).to.be.a(ol.expr.Literal);
|
||||||
expect(expr.getValue()).to.equal(10);
|
expect(expr.getValue()).to.equal(10);
|
||||||
xml = '<ogc:UpperBoundary xmlns:ogc="http://www.opengis.net/ogc">' +
|
xml = '<ogc:UpperBoundary xmlns:ogc="http://www.opengis.net/ogc">' +
|
||||||
'foo<ogc:PropertyName>x</ogc:PropertyName>bar</ogc:UpperBoundary>';
|
'foo<ogc:PropertyName>x</ogc:PropertyName>bar</ogc:UpperBoundary>';
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ describe('ol.parser.ogc.Filter_v1_1_0', function() {
|
|||||||
|
|
||||||
var parser = new ol.parser.ogc.Filter_v1_1_0();
|
var parser = new ol.parser.ogc.Filter_v1_1_0();
|
||||||
|
|
||||||
describe('#readwrite', function() {
|
describe('reading and writing', function() {
|
||||||
|
|
||||||
it('filter read correctly', function(done) {
|
it('reads filter', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_1_0/test.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_1_0/test.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var filter = parser.read(xml);
|
var filter = parser.read(xml);
|
||||||
@@ -45,7 +45,7 @@ describe('ol.parser.ogc.Filter_v1_1_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('matchCase read correctly', function() {
|
it('reads matchCase', function() {
|
||||||
var cases = [{
|
var cases = [{
|
||||||
str:
|
str:
|
||||||
'<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">' +
|
'<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">' +
|
||||||
@@ -119,7 +119,7 @@ describe('ol.parser.ogc.Filter_v1_1_0', function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('BBOX filter written correctly', function(done) {
|
it('writes BBOX', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_1_0/bbox.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_1_0/bbox.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var filter = parser.read(xml);
|
var filter = parser.read(xml);
|
||||||
@@ -129,7 +129,7 @@ describe('ol.parser.ogc.Filter_v1_1_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('BBOX filter without property name written correctly', function(done) {
|
it('writes BBOX without property name', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_1_0/bbox_nogeomname.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_1_0/bbox_nogeomname.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var filter = parser.read(xml);
|
var filter = parser.read(xml);
|
||||||
@@ -139,7 +139,7 @@ describe('ol.parser.ogc.Filter_v1_1_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Intersects filter read / written correctly', function(done) {
|
it('handles intersects', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_1_0/intersects.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_1_0/intersects.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var filter = parser.read(xml);
|
var filter = parser.read(xml);
|
||||||
@@ -149,7 +149,7 @@ describe('ol.parser.ogc.Filter_v1_1_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Filter functions written correctly', function(done) {
|
it('handles functions', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_1_0/function.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_1_0/function.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var filter = new ol.expr.Call(new ol.expr.Identifier(
|
var filter = new ol.expr.Call(new ol.expr.Identifier(
|
||||||
@@ -165,7 +165,7 @@ describe('ol.parser.ogc.Filter_v1_1_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Custom filter functions written correctly', function(done) {
|
it('writes custom functions', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_1_0/customfunction.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_1_0/customfunction.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var filter = new ol.expr.Logical(ol.expr.LogicalOp.AND,
|
var filter = new ol.expr.Logical(ol.expr.LogicalOp.AND,
|
||||||
@@ -179,7 +179,7 @@ describe('ol.parser.ogc.Filter_v1_1_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Nested filter functions written correctly', function(done) {
|
it('writes nested functions', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_1_0/nestedfunction.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_1_0/nestedfunction.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var filter = new ol.expr.Call(new ol.expr.Identifier(
|
var filter = new ol.expr.Call(new ol.expr.Identifier(
|
||||||
@@ -197,7 +197,7 @@ describe('ol.parser.ogc.Filter_v1_1_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('matchCase written correctly on Like filter', function(done) {
|
it('writes matchCase on like', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_1_0/likematchcase.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_1_0/likematchcase.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var filter = new ol.expr.Call(
|
var filter = new ol.expr.Call(
|
||||||
@@ -211,7 +211,7 @@ describe('ol.parser.ogc.Filter_v1_1_0', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sortBy written correctly on Like filter', function(done) {
|
it('writes sortBy on like', function(done) {
|
||||||
var url = 'spec/ol/parser/ogc/xml/filter_v1_1_0/sortby.xml';
|
var url = 'spec/ol/parser/ogc/xml/filter_v1_1_0/sortby.xml';
|
||||||
afterLoadXml(url, function(xml) {
|
afterLoadXml(url, function(xml) {
|
||||||
var writer = parser.writers['http://www.opengis.net/ogc']['SortBy'];
|
var writer = parser.writers['http://www.opengis.net/ogc']['SortBy'];
|
||||||
|
|||||||
Reference in New Issue
Block a user