Files
openlayers/tests/Rule.html
pgiraud 815e55888a context can now be given as argument in StyleMap.addUniqueValueRules()
this, for example, allows user to access to properties that are not part of the feature attributes.
r=elemoine (closes #1548)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@7216 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2008-05-19 13:34:35 +00:00

57 lines
1.6 KiB
HTML

<html>
<head>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
function test_Rule_constructor(t) {
t.plan(3);
var options = {'foo': 'bar'};
var rule = new OpenLayers.Rule(options);
t.ok(rule instanceof OpenLayers.Rule,
"new OpenLayers.Rule returns object" );
t.eq(rule.foo, "bar", "constructor sets options correctly");
t.eq(typeof rule.evaluate, "function", "rule has an evaluate function");
}
function test_Rule_getContext(t) {
t.plan(2);
var rule, options;
var feature = {
attributes: {
'dude': 'hello'
},
'foobar': 'world'
}
rule = new OpenLayers.Rule();
var context = rule.getContext(feature);
t.eq(context.dude, "hello", "value returned by getContext is correct"
+ " if no context is specified");
var options = {
context: function(feature){
return feature;
}
};
rule = new OpenLayers.Rule(options);
var context = rule.getContext(feature);
t.eq(context.foobar, "world", "value returned by getContext is correct"
+ " if a context is given in constructor options");
}
function test_Rule_destroy(t) {
t.plan(1);
var rule = new OpenLayers.Rule();
rule.destroy();
t.eq(rule.symbolizer, null, "symbolizer hash nulled properly");
}
</script>
</head>
<body>
</body>
</html>